commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1378966 - in /commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary: Base32.java Base64.java
Date Thu, 30 Aug 2012 14:44:23 GMT
Author: ggregory
Date: Thu Aug 30 14:44:23 2012
New Revision: 1378966

URL: http://svn.apache.org/viewvc?rev=1378966&view=rev
Log:
Use final on some lvars to clarify intent and avoid potential bugs. Should final be applied
all over?

Modified:
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java?rev=1378966&r1=1378965&r2=1378966&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base32.java Thu
Aug 30 14:44:23 2012
@@ -289,7 +289,7 @@ public class Base32 extends BaseNCodec {
             context.eof = true;
         }
         for (int i = 0; i < inAvail; i++) {
-            byte b = in[inPos++];
+            final byte b = in[inPos++];
             if (b == PAD) {
                 // We're done.
                 context.eof = true;
@@ -297,7 +297,7 @@ public class Base32 extends BaseNCodec {
             } else {
                 final byte[] buffer = ensureBufferSize(decodeSize, context);
                 if (b >= 0 && b < this.decodeTable.length) {
-                    int result = this.decodeTable[b];
+                    final int result = this.decodeTable[b];
                     if (result >= 0) {
                         context.modulus = (context.modulus+1) % BYTES_PER_ENCODED_BLOCK;
                         // collect decoded bytes
@@ -384,7 +384,7 @@ public class Base32 extends BaseNCodec {
                 return; // no leftovers to process and not using chunking
             }
             final byte[] buffer = ensureBufferSize(encodeSize, context);
-            int savedPos = context.pos;
+            final int savedPos = context.pos;
             switch (context.modulus) { // % 5
                 case 1 : // Only 1 octet; take top 5 bits then remainder
                     buffer[context.pos++] = encodeTable[(int)(context.lbitWorkArea >>
3) & MASK_5BITS]; // 8-1*5 = 3

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java?rev=1378966&r1=1378965&r2=1378966&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java (original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/Base64.java Thu
Aug 30 14:44:23 2012
@@ -335,7 +335,7 @@ public class Base64 extends BaseNCodec {
                 return; // no leftovers to process and not using chunking
             }
             final byte[] buffer = ensureBufferSize(encodeSize, context);
-            int savedPos = context.pos;
+            final int savedPos = context.pos;
             switch (context.modulus) { // 0-2
                 case 1 : // 8 bits = 6 + 2
                     // top 6 bits:



Mime
View raw message