diff options
| author | Eli Zaretskii | 2018-04-28 10:41:27 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2018-04-28 10:41:27 +0300 |
| commit | 0b3bc05d15c32ffa134347896c9b9fcff89225ab (patch) | |
| tree | 8c16eedb76ae5b3f2d17fa526abbfed06bd557a7 /src | |
| parent | a7a3918a16c85f89d797d48b09e751ab30e0f032 (diff) | |
| download | emacs-0b3bc05d15c32ffa134347896c9b9fcff89225ab.tar.gz emacs-0b3bc05d15c32ffa134347896c9b9fcff89225ab.zip | |
* src/fns.c (Fstring_distance): Minor code reformatting.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 13 |
1 files changed, 8 insertions, 5 deletions
| @@ -166,10 +166,11 @@ Letter-case is significant, but text properties are ignored. */) | |||
| 166 | CHECK_STRING (string1); | 166 | CHECK_STRING (string1); |
| 167 | CHECK_STRING (string2); | 167 | CHECK_STRING (string2); |
| 168 | 168 | ||
| 169 | bool use_byte_compare = !NILP (bytecompare) | 169 | bool use_byte_compare = |
| 170 | !NILP (bytecompare) | ||
| 170 | || (!STRING_MULTIBYTE (string1) && !STRING_MULTIBYTE (string2)); | 171 | || (!STRING_MULTIBYTE (string1) && !STRING_MULTIBYTE (string2)); |
| 171 | ptrdiff_t len1 = use_byte_compare? SBYTES (string1) : SCHARS (string1); | 172 | ptrdiff_t len1 = use_byte_compare ? SBYTES (string1) : SCHARS (string1); |
| 172 | ptrdiff_t len2 = use_byte_compare? SBYTES (string2) : SCHARS (string2); | 173 | ptrdiff_t len2 = use_byte_compare ? SBYTES (string2) : SCHARS (string2); |
| 173 | ptrdiff_t x, y, lastdiag, olddiag; | 174 | ptrdiff_t x, y, lastdiag, olddiag; |
| 174 | 175 | ||
| 175 | USE_SAFE_ALLOCA; | 176 | USE_SAFE_ALLOCA; |
| @@ -188,7 +189,8 @@ Letter-case is significant, but text properties are ignored. */) | |||
| 188 | for (y = 1, lastdiag = x - 1; y <= len1; y++) | 189 | for (y = 1, lastdiag = x - 1; y <= len1; y++) |
| 189 | { | 190 | { |
| 190 | olddiag = column[y]; | 191 | olddiag = column[y]; |
| 191 | column[y] = min (min (column[y] + 1, column[y-1] + 1), lastdiag + (s1[y-1] == s2[x-1]? 0 : 1)); | 192 | column[y] = min (min (column[y] + 1, column[y-1] + 1), |
| 193 | lastdiag + (s1[y-1] == s2[x-1] ? 0 : 1)); | ||
| 192 | lastdiag = olddiag; | 194 | lastdiag = olddiag; |
| 193 | } | 195 | } |
| 194 | } | 196 | } |
| @@ -206,7 +208,8 @@ Letter-case is significant, but text properties are ignored. */) | |||
| 206 | { | 208 | { |
| 207 | olddiag = column[y]; | 209 | olddiag = column[y]; |
| 208 | FETCH_STRING_CHAR_ADVANCE (c1, string1, i1, i1_byte); | 210 | FETCH_STRING_CHAR_ADVANCE (c1, string1, i1, i1_byte); |
| 209 | column[y] = min (min (column[y] + 1, column[y-1] + 1), lastdiag + (c1 == c2? 0 : 1)); | 211 | column[y] = min (min (column[y] + 1, column[y-1] + 1), |
| 212 | lastdiag + (c1 == c2 ? 0 : 1)); | ||
| 210 | lastdiag = olddiag; | 213 | lastdiag = olddiag; |
| 211 | } | 214 | } |
| 212 | } | 215 | } |