[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 0b3bc05: * src/fns.c (Fstring_distance): Minor code
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] master 0b3bc05: * src/fns.c (Fstring_distance): Minor code reformatting. |
Date: |
Sat, 28 Apr 2018 03:42:31 -0400 (EDT) |
branch: master
commit 0b3bc05d15c32ffa134347896c9b9fcff89225ab
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
* src/fns.c (Fstring_distance): Minor code reformatting.
---
src/fns.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/fns.c b/src/fns.c
index 1d69f15..c171784 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -166,10 +166,11 @@ Letter-case is significant, but text properties are
ignored. */)
CHECK_STRING (string1);
CHECK_STRING (string2);
- bool use_byte_compare = !NILP (bytecompare)
+ bool use_byte_compare =
+ !NILP (bytecompare)
|| (!STRING_MULTIBYTE (string1) && !STRING_MULTIBYTE (string2));
- ptrdiff_t len1 = use_byte_compare? SBYTES (string1) : SCHARS (string1);
- ptrdiff_t len2 = use_byte_compare? SBYTES (string2) : SCHARS (string2);
+ ptrdiff_t len1 = use_byte_compare ? SBYTES (string1) : SCHARS (string1);
+ ptrdiff_t len2 = use_byte_compare ? SBYTES (string2) : SCHARS (string2);
ptrdiff_t x, y, lastdiag, olddiag;
USE_SAFE_ALLOCA;
@@ -188,7 +189,8 @@ Letter-case is significant, but text properties are
ignored. */)
for (y = 1, lastdiag = x - 1; y <= len1; y++)
{
olddiag = column[y];
- column[y] = min (min (column[y] + 1, column[y-1] + 1), lastdiag
+ (s1[y-1] == s2[x-1]? 0 : 1));
+ column[y] = min (min (column[y] + 1, column[y-1] + 1),
+ lastdiag + (s1[y-1] == s2[x-1] ? 0 : 1));
lastdiag = olddiag;
}
}
@@ -206,7 +208,8 @@ Letter-case is significant, but text properties are
ignored. */)
{
olddiag = column[y];
FETCH_STRING_CHAR_ADVANCE (c1, string1, i1, i1_byte);
- column[y] = min (min (column[y] + 1, column[y-1] + 1), lastdiag
+ (c1 == c2? 0 : 1));
+ column[y] = min (min (column[y] + 1, column[y-1] + 1),
+ lastdiag + (c1 == c2 ? 0 : 1));
lastdiag = olddiag;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 0b3bc05: * src/fns.c (Fstring_distance): Minor code reformatting.,
Eli Zaretskii <=