You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2014/01/23 18:07:47 UTC
svn commit: r1560756 -
/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
Author: britter
Date: Thu Jan 23 17:07:46 2014
New Revision: 1560756
URL: http://svn.apache.org/r1560756
Log:
Reuse code already available in StringUtils
Modified:
commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java?rev=1560756&r1=1560755&r2=1560756&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java Thu Jan 23 17:07:46 2014
@@ -7123,27 +7123,7 @@ public class StringUtils {
* @return A number between 0 and 4.
*/
private static int commonPrefixLength(CharSequence first, CharSequence second) {
- String shorter;
- String longer;
-
- // Determine which String is longer.
- if (first.length() > second.length()) {
- longer = first.toString().toLowerCase();
- shorter = second.toString().toLowerCase();
- } else {
- longer = second.toString().toLowerCase();
- shorter = first.toString().toLowerCase();
- }
-
- int result = 0;
-
- // Iterate through the shorter string.
- for (int i = 0; i < shorter.length(); i++) {
- if (shorter.charAt(i) != longer.charAt(i)) {
- break;
- }
- result++;
- }
+ final int result = getCommonPrefix(first.toString(), second.toString()).length();
// Limit the result to 4.
return result > 4 ? 4 : result;