commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r1056998 - /commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/StringUtils.java
Date Sun, 09 Jan 2011 18:44:03 GMT
Author: niallp
Date: Sun Jan  9 18:44:03 2011
New Revision: 1056998

URL: http://svn.apache.org/viewvc?rev=1056998&view=rev
Log:
Minor optimization of normalizeSpace()

Modified:
    commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/StringUtils.java

Modified: commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/StringUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/StringUtils.java?rev=1056998&r1=1056997&r2=1056998&view=diff
==============================================================================
--- commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/StringUtils.java
(original)
+++ commons/proper/lang/branches/LANG_2_X/src/main/java/org/apache/commons/lang/StringUtils.java
Sun Jan  9 18:44:03 2011
@@ -6536,10 +6536,10 @@ public class StringUtils {
      * @since 2.6
      */
     public static String normalizeSpace(String str) {
-        if(str == null) {
-            return null;
-        }
         str = trim(str);
+        if(str == null || str.length() <= 2) {
+            return str;
+        }
         StringBuffer b = new StringBuffer(str.length());
         for (int i = 0; i < str.length(); i++) {
             char c = str.charAt(i);



Mime
View raw message