Applying Cedrik Lime's patch to LANG-413; improving the memory footprint of getLevenshteinDistance
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@630580 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5cbca4d5f5
commit
68c6547d0c
|
@ -5737,6 +5737,15 @@ public class StringUtils {
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue