felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kgil...@apache.org
Subject svn commit: r1221756 - /felix/trunk/httplite/minimum/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
Date Wed, 21 Dec 2011 15:07:40 GMT
Author: kgilmer
Date: Wed Dec 21 15:07:39 2011
New Revision: 1221756

URL: http://svn.apache.org/viewvc?rev=1221756&view=rev
Log:
httplite: more consise implementation of String.split() by Yann Diorcet.  See FELIX-3287

Modified:
    felix/trunk/httplite/minimum/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java

Modified: felix/trunk/httplite/minimum/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/httplite/minimum/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java?rev=1221756&r1=1221755&r2=1221756&view=diff
==============================================================================
--- felix/trunk/httplite/minimum/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
(original)
+++ felix/trunk/httplite/minimum/src/main/java/org/apache/felix/httplite/servlet/HttpServletRequestImpl.java
Wed Dec 21 15:07:39 2011
@@ -1151,47 +1151,17 @@ public class HttpServletRequestImpl impl
      */
     private static String[] splitString( String instr, char separator )
     {
-        if ( instr == null )
+		if ( instr == null )
         {
             throw new IllegalArgumentException( "Input string must not be null." );
         }
 
-        if ( instr.length() == 0 )
+	    StringTokenizer tokenizer = new StringTokenizer(instr, Character.toString(separator));
+        int length = tokenizer.countTokens();
+		String[] str_array = new String[length];
+        for ( int i = 0; i < length; i++ )
         {
-            return ( new String[0] );
-        }
-
-        List tokens = new ArrayList();
-        String token;
-        int index_a = 0;
-        int index_b = 0;
-
-        while ( true )
-        {
-            index_b = instr.indexOf( separator, index_a );
-            if ( index_b == -1 )
-            {
-                token = instr.substring( index_a );
-
-                if ( token.length() > 0 )
-                {
-                    tokens.add( token );
-                }
-
-                break;
-            }
-            token = instr.substring( index_a, index_b );
-
-            if ( token.length() >= 0 )
-            {
-                tokens.add( token );
-            }
-            index_a = index_b + 1;
-        }
-        String[] str_array = new String[tokens.size()];
-        for ( int i = 0; i < str_array.length; i++ )
-        {
-            str_array[i] = ( String ) ( tokens.get( i ) );
+            str_array[i] = tokenizer.nextToken();
         }
         return str_array;
     }



Mime
View raw message