river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r1463118 - /river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/URIEncoderDecoder.java
Date Mon, 01 Apr 2013 09:23:18 GMT
Author: peter_firmstone
Date: Mon Apr  1 09:23:18 2013
New Revision: 1463118

URL: http://svn.apache.org/r1463118
Log:
Performance enhancement,eliminate calls to String.length() during for loop.

Modified:
    river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/URIEncoderDecoder.java

Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/URIEncoderDecoder.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/URIEncoderDecoder.java?rev=1463118&r1=1463117&r2=1463118&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/URIEncoderDecoder.java
(original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/URIEncoderDecoder.java
Mon Apr  1 09:23:18 2013
@@ -227,12 +227,13 @@ class URIEncoderDecoder {
 
         StringBuilder result = new StringBuilder();
         ByteArrayOutputStream out = new ByteArrayOutputStream();
-        for (int i = 0; i < s.length();) {
+        int l = s.length();
+        for (int i = 0; i < l;) {
             char c = s.charAt(i);
             if (c == '%') {
                 out.reset();
                 do {
-                    if (i + 2 >= s.length()) {
+                    if (i + 2 >= l) {
                         throw new IllegalArgumentException(Messages.getString(
                                 "luni.80", i)); //$NON-NLS-1$
                     }
@@ -245,7 +246,7 @@ class URIEncoderDecoder {
                     }
                     out.write((byte) ((d1 << 4) + d2));
                     i += 3;
-                } while (i < s.length() && s.charAt(i) == '%');
+                } while (i < l && s.charAt(i) == '%');
                 result.append(out.toString(encoding));
                 continue;
             }



Mime
View raw message