You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by pa...@apache.org on 2016/05/21 14:50:21 UTC

[1/2] [lang] LANG-1234: getLevenshteinDistance with a threshold: optimize implementation if the strings lengths differ more than the threshold (closes #118)

Repository: commons-lang
Updated Branches:
  refs/heads/master 031f6b082 -> 49455b78b


LANG-1234: getLevenshteinDistance with a threshold: optimize implementation if the strings lengths differ more than the threshold (closes #118)

If the string lengths differ more than the threshold, there's no need for the algorithm to begin allocating arrays etc.


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/04b41e2c
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/04b41e2c
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/04b41e2c

Branch: refs/heads/master
Commit: 04b41e2c97fe5faaf521c2e0581c30e18e2f0c27
Parents: 031f6b0
Author: Jonatan J�nsson <jo...@gmail.com>
Authored: Thu Nov 26 10:23:15 2015 +0100
Committer: pascalschumacher <pa...@gmx.net>
Committed: Sat May 21 16:47:59 2016 +0200

----------------------------------------------------------------------
 src/main/java/org/apache/commons/lang3/StringUtils.java | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/04b41e2c/src/main/java/org/apache/commons/lang3/StringUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java
index 31a572a..c169e0a 100644
--- a/src/main/java/org/apache/commons/lang3/StringUtils.java
+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java
@@ -7585,6 +7585,10 @@ public class StringUtils {
         } else if (m == 0) {
             return n <= threshold ? n : -1;
         }
+        // no need to calculate the distance if the length difference is greater than the threshold
+        else if (Math.abs(n - m) > threshold) {
+            return -1;
+        }
 
         if (n > m) {
             // swap the two strings to consume less memory


[2/2] [lang] LANG-1234: add changes.xml entry

Posted by pa...@apache.org.
LANG-1234: add changes.xml entry


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/49455b78
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/49455b78
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/49455b78

Branch: refs/heads/master
Commit: 49455b78bfc960de70acff552baeafbb705e80a7
Parents: 04b41e2
Author: pascalschumacher <pa...@gmx.net>
Authored: Sat May 21 16:50:10 2016 +0200
Committer: pascalschumacher <pa...@gmx.net>
Committed: Sat May 21 16:50:10 2016 +0200

----------------------------------------------------------------------
 src/changes/changes.xml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/49455b78/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 034de39..4dd3cbf 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -22,6 +22,7 @@
   <body>
 
   <release version="3.5" date="tba" description="tba">
+    <action issue="LANG-1234" type="update" dev="pschumacher" due-to="Jonatan J�nsson">getLevenshteinDistance with a threshold: optimize implementation if the strings lengths differ more than the threshold</action>
     <action issue="LANG-1168" type="add" dev="pschumacher" due-to="pschumacher">Add SystemUtils.IS_OS_WINDOWS_10 property</action>
     <action issue="LANG-1232" type="fix" dev="pschumacher" due-to="Nick Manley">DiffBuilder: Add null check on fieldName when appending Object or Object[]</action>
     <action issue="LANG-1178" type="fix" dev="pschumacher" due-to="Henri Yandell">ArrayUtils.removeAll(Object array, int... indices) should do the clone, not its callers</action>