commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r630580 - /commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java
Date Sun, 24 Feb 2008 03:33:49 GMT
Author: bayard
Date: Sat Feb 23 19:33:49 2008
New Revision: 630580

URL: http://svn.apache.org/viewvc?rev=630580&view=rev
Log:
Applying Cedrik Lime's patch to LANG-413; improving the memory footprint of getLevenshteinDistance

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java?rev=630580&r1=630579&r2=630580&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java Sat Feb 23
19:33:49 2008
@@ -5737,6 +5737,15 @@
             return n;
         }
 
+        if (n > m) {
+            // swap the input strings to consume less memory
+            String tmp = s;
+            s = t;
+            t = tmp;
+            n = m;
+            m = t.length();
+        }
+
         int p[] = new int[n+1]; //'previous' cost array, horizontally
         int d[] = new int[n+1]; // cost array, horizontally
         int _d[]; //placeholder to assist in swapping p and d



Mime
View raw message