Followup to implementation of https://issues.apache.org/bugzilla/show_bug.cgi?id...
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 11 Nov 2010 08:53:01 +0000 (08:53 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 11 Nov 2010 08:53:01 +0000 (08:53 +0000)
Use local variable instead of array access.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1033842 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/http11/filters/ChunkedInputFilter.java

index cd09acc..e9e83c1 100644 (file)
@@ -420,8 +420,6 @@ public class ChunkedInputFilter implements InputFilter {
         //
     
         boolean colon = false;
-        MessageBytes headerValue = null;
-    
         while (!colon) {
     
             // Read new bytes if needed
@@ -432,20 +430,20 @@ public class ChunkedInputFilter implements InputFilter {
     
             chr = buf[pos];
             if ((chr >= Constants.A) && (chr <= Constants.Z)) {
-                buf[pos] = (byte) (chr - Constants.LC_OFFSET);
+                chr = (byte) (chr - Constants.LC_OFFSET);
             }
 
-            if (buf[pos] == Constants.COLON) {
+            if (chr == Constants.COLON) {
                 colon = true;
             } else {
-                trailingHeaders.append(buf[pos]);
+                trailingHeaders.append(chr);
             }
     
             pos++;
     
         }
-        headerValue = headers.addValue(trailingHeaders.getBytes(), start,
-                trailingHeaders.getEnd() - start);
+        MessageBytes headerValue = headers.addValue(trailingHeaders.getBytes(),
+                start, trailingHeaders.getEnd() - start);
     
         // Mark the current buffer position
         start = trailingHeaders.getEnd();
@@ -471,7 +469,8 @@ public class ChunkedInputFilter implements InputFilter {
                         throw new EOFException("Unexpected end of stream whilst reading trailer headers for chunked request");
                 }
     
-                if ((buf[pos] == Constants.SP) || (buf[pos] == Constants.HT)) {
+                chr = buf[pos];
+                if ((chr == Constants.SP) || (chr == Constants.HT)) {
                     pos++;
                 } else {
                     space = false;
@@ -488,14 +487,15 @@ public class ChunkedInputFilter implements InputFilter {
                         throw new EOFException("Unexpected end of stream whilst reading trailer headers for chunked request");
                 }
     
-                if (buf[pos] == Constants.CR) {
+                chr = buf[pos];
+                if (chr == Constants.CR) {
                     // Skip
-                } else if (buf[pos] == Constants.LF) {
+                } else if (chr == Constants.LF) {
                     eol = true;
-                } else if (buf[pos] == Constants.SP) {
-                    trailingHeaders.append(buf[pos]);
+                } else if (chr == Constants.SP) {
+                    trailingHeaders.append(chr);
                 } else {
-                    trailingHeaders.append(buf[pos]);
+                    trailingHeaders.append(chr);
                     lastSignificantChar = trailingHeaders.getEnd();
                 }