LANG-1277: StringUtils#getLevenshteinDistance reduce memory consumption
minimal clean-up add changes.xml entry
This commit is contained in:
parent
103b64a373
commit
6423a76655
|
@ -46,6 +46,7 @@ The <action> type attribute can be add,update,fix,remove.
|
|||
<body>
|
||||
|
||||
<release version="3.6" date="tba" description="tba">
|
||||
<action issue="LANG-1277" type="update" dev="pschumacher" due-to="yufcuy">StringUtils#getLevenshteinDistance reduce memory consumption</action>
|
||||
<action issue="LANG-1070" type="fix" dev="pschumacher" due-to="Paul Pogonyshev">ArrayUtils#add confusing example in javadoc</action>
|
||||
<action issue="LANG-1271" type="fix" dev="pschumacher" due-to="Pierre Templier">StringUtils#isAnyEmpty and #isAnyBlank should return false for an empty array</action>
|
||||
<action issue="LANG-1270" type="add" dev="pschumacher" due-to="Pierre Templier">Add StringUtils#isAnyNotEmpty and #isAnyNotBlank</action>
|
||||
|
|
|
@ -7736,11 +7736,9 @@ public class StringUtils {
|
|||
* another, where each change is a single character modification (deletion,
|
||||
* insertion or substitution).</p>
|
||||
*
|
||||
* <p>The previous implementation of the Levenshtein distance algorithm
|
||||
* was from <a href="https://web.archive.org/web/20120526085419/http://www.merriampark.com/ldjava.htm">
|
||||
* https://web.archive.org/web/20120526085419/http://www.merriampark.com/ldjava.htm</a></p>
|
||||
*
|
||||
* <p>This implementation only need one single-dimensional arrays of length s.length() + 1</p>
|
||||
* <p>The implementation uses a single-dimensional array of length s.length() + 1. See
|
||||
* <a href="http://blog.softwx.net/2014/12/optimizing-levenshtein-algorithm-in-c.html">
|
||||
* http://blog.softwx.net/2014/12/optimizing-levenshtein-algorithm-in-c.html</a> for details.</p>
|
||||
*
|
||||
* <pre>
|
||||
* StringUtils.getLevenshteinDistance(null, *) = IllegalArgumentException
|
||||
|
@ -7768,13 +7766,8 @@ public class StringUtils {
|
|||
throw new IllegalArgumentException("Strings must not be null");
|
||||
}
|
||||
|
||||
/*
|
||||
This implementation use two variable to record the previous cost counts,
|
||||
So this implementation use less memory than previous impl.
|
||||
*/
|
||||
|
||||
int n = s.length(); // length of s
|
||||
int m = t.length(); // length of t
|
||||
int n = s.length();
|
||||
int m = t.length();
|
||||
|
||||
if (n == 0) {
|
||||
return m;
|
||||
|
@ -7799,7 +7792,7 @@ public class StringUtils {
|
|||
int upper;
|
||||
|
||||
char t_j; // jth character of t
|
||||
int cost; // cost
|
||||
int cost;
|
||||
|
||||
for (i = 0; i <= n; i++) {
|
||||
p[i] = i;
|
||||
|
|
Loading…
Reference in New Issue