You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2015/04/06 21:21:51 UTC

svn commit: r1671661 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Conversion.java

Author: britter
Date: Mon Apr  6 19:21:51 2015
New Revision: 1671661

URL: http://svn.apache.org/r1671661
Log:
Scope of local variabel shift can be narrower

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Conversion.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Conversion.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Conversion.java?rev=1671661&r1=1671660&r2=1671661&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Conversion.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/Conversion.java Mon Apr  6 19:21:51 2015
@@ -582,9 +582,8 @@ public class Conversion {
             throw new IllegalArgumentException("(nInts-1)*32+dstPos is greather or equal to than 64");
         }
         long out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nInts; i++) {
-            shift = i * 32 + dstPos;
+            final int shift = i * 32 + dstPos;
             final long bits = (0xffffffffL & src[i + srcPos]) << shift;
             final long mask = 0xffffffffL << shift;
             out = (out & ~mask) | bits;
@@ -618,9 +617,8 @@ public class Conversion {
             throw new IllegalArgumentException("(nShorts-1)*16+dstPos is greather or equal to than 64");
         }
         long out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nShorts; i++) {
-            shift = i * 16 + dstPos;
+            final int shift = i * 16 + dstPos;
             final long bits = (0xffffL & src[i + srcPos]) << shift;
             final long mask = 0xffffL << shift;
             out = (out & ~mask) | bits;
@@ -654,9 +652,8 @@ public class Conversion {
             throw new IllegalArgumentException("(nShorts-1)*16+dstPos is greather or equal to than 32");
         }
         int out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nShorts; i++) {
-            shift = i * 16 + dstPos;
+            final int shift = i * 16 + dstPos;
             final int bits = (0xffff & src[i + srcPos]) << shift;
             final int mask = 0xffff << shift;
             out = (out & ~mask) | bits;
@@ -690,9 +687,8 @@ public class Conversion {
             throw new IllegalArgumentException("(nBytes-1)*8+dstPos is greather or equal to than 64");
         }
         long out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nBytes; i++) {
-            shift = i * 8 + dstPos;
+            final int shift = i * 8 + dstPos;
             final long bits = (0xffL & src[i + srcPos]) << shift;
             final long mask = 0xffL << shift;
             out = (out & ~mask) | bits;
@@ -726,9 +722,8 @@ public class Conversion {
             throw new IllegalArgumentException("(nBytes-1)*8+dstPos is greather or equal to than 32");
         }
         int out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nBytes; i++) {
-            shift = i * 8 + dstPos;
+            final int shift = i * 8 + dstPos;
             final int bits = (0xff & src[i + srcPos]) << shift;
             final int mask = 0xff << shift;
             out = (out & ~mask) | bits;
@@ -762,9 +757,8 @@ public class Conversion {
             throw new IllegalArgumentException("(nBytes-1)*8+dstPos is greather or equal to than 16");
         }
         short out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nBytes; i++) {
-            shift = i * 8 + dstPos;
+            final int shift = i * 8 + dstPos;
             final int bits = (0xff & src[i + srcPos]) << shift;
             final int mask = 0xff << shift;
             out = (short) ((out & ~mask) | bits);
@@ -796,9 +790,8 @@ public class Conversion {
             throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greather or equal to than 64");
         }
         long out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nHex; i++) {
-            shift = i * 4 + dstPos;
+            final int shift = i * 4 + dstPos;
             final long bits = (0xfL & hexDigitToInt(src.charAt(i + srcPos))) << shift;
             final long mask = 0xfL << shift;
             out = (out & ~mask) | bits;
@@ -829,9 +822,8 @@ public class Conversion {
             throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greather or equal to than 32");
         }
         int out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nHex; i++) {
-            shift = i * 4 + dstPos;
+            final int shift = i * 4 + dstPos;
             final int bits = (0xf & hexDigitToInt(src.charAt(i + srcPos))) << shift;
             final int mask = 0xf << shift;
             out = (out & ~mask) | bits;
@@ -863,9 +855,8 @@ public class Conversion {
             throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greather or equal to than 16");
         }
         short out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nHex; i++) {
-            shift = i * 4 + dstPos;
+            final int shift = i * 4 + dstPos;
             final int bits = (0xf & hexDigitToInt(src.charAt(i + srcPos))) << shift;
             final int mask = 0xf << shift;
             out = (short) ((out & ~mask) | bits);
@@ -897,9 +888,8 @@ public class Conversion {
             throw new IllegalArgumentException("(nHexs-1)*4+dstPos is greather or equal to than 8");
         }
         byte out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nHex; i++) {
-            shift = i * 4 + dstPos;
+            final int shift = i * 4 + dstPos;
             final int bits = (0xf & hexDigitToInt(src.charAt(i + srcPos))) << shift;
             final int mask = 0xf << shift;
             out = (byte) ((out & ~mask) | bits);
@@ -933,9 +923,8 @@ public class Conversion {
             throw new IllegalArgumentException("nBools-1+dstPos is greather or equal to than 64");
         }
         long out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nBools; i++) {
-            shift = i + dstPos;
+            final int shift = i + dstPos;
             final long bits = (src[i + srcPos] ? 1L : 0) << shift;
             final long mask = 0x1L << shift;
             out = (out & ~mask) | bits;
@@ -969,9 +958,8 @@ public class Conversion {
             throw new IllegalArgumentException("nBools-1+dstPos is greather or equal to than 32");
         }
         int out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nBools; i++) {
-            shift = i + dstPos;
+            final int shift = i + dstPos;
             final int bits = (src[i + srcPos] ? 1 : 0) << shift;
             final int mask = 0x1 << shift;
             out = (out & ~mask) | bits;
@@ -1005,9 +993,8 @@ public class Conversion {
             throw new IllegalArgumentException("nBools-1+dstPos is greather or equal to than 16");
         }
         short out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nBools; i++) {
-            shift = i + dstPos;
+            final int shift = i + dstPos;
             final int bits = (src[i + srcPos] ? 1 : 0) << shift;
             final int mask = 0x1 << shift;
             out = (short) ((out & ~mask) | bits);
@@ -1041,9 +1028,8 @@ public class Conversion {
             throw new IllegalArgumentException("nBools-1+dstPos is greather or equal to than 8");
         }
         byte out = dstInit;
-        int shift = 0;
         for (int i = 0; i < nBools; i++) {
-            shift = i + dstPos;
+            final int shift = i + dstPos;
             final int bits = (src[i + srcPos] ? 1 : 0) << shift;
             final int mask = 0x1 << shift;
             out = (byte) ((out & ~mask) | bits);
@@ -1076,9 +1062,8 @@ public class Conversion {
         if ((nInts - 1) * 32 + srcPos >= 64) {
             throw new IllegalArgumentException("(nInts-1)*32+srcPos is greather or equal to than 64");
         }
-        int shift = 0;
         for (int i = 0; i < nInts; i++) {
-            shift = i * 32 + srcPos;
+            final int shift = i * 32 + srcPos;
             dst[dstPos + i] = (int) (0xffffffff & (src >> shift));
         }
         return dst;
@@ -1109,9 +1094,8 @@ public class Conversion {
         if ((nShorts - 1) * 16 + srcPos >= 64) {
             throw new IllegalArgumentException("(nShorts-1)*16+srcPos is greather or equal to than 64");
         }
-        int shift = 0;
         for (int i = 0; i < nShorts; i++) {
-            shift = i * 16 + srcPos;
+            final int shift = i * 16 + srcPos;
             dst[dstPos + i] = (short) (0xffff & (src >> shift));
         }
         return dst;
@@ -1142,9 +1126,8 @@ public class Conversion {
         if ((nShorts - 1) * 16 + srcPos >= 32) {
             throw new IllegalArgumentException("(nShorts-1)*16+srcPos is greather or equal to than 32");
         }
-        int shift = 0;
         for (int i = 0; i < nShorts; i++) {
-            shift = i * 16 + srcPos;
+            final int shift = i * 16 + srcPos;
             dst[dstPos + i] = (short) (0xffff & (src >> shift));
         }
         return dst;
@@ -1175,9 +1158,8 @@ public class Conversion {
         if ((nBytes - 1) * 8 + srcPos >= 64) {
             throw new IllegalArgumentException("(nBytes-1)*8+srcPos is greather or equal to than 64");
         }
-        int shift = 0;
         for (int i = 0; i < nBytes; i++) {
-            shift = i * 8 + srcPos;
+            final int shift = i * 8 + srcPos;
             dst[dstPos + i] = (byte) (0xff & (src >> shift));
         }
         return dst;
@@ -1208,9 +1190,8 @@ public class Conversion {
         if ((nBytes - 1) * 8 + srcPos >= 32) {
             throw new IllegalArgumentException("(nBytes-1)*8+srcPos is greather or equal to than 32");
         }
-        int shift = 0;
         for (int i = 0; i < nBytes; i++) {
-            shift = i * 8 + srcPos;
+            final int shift = i * 8 + srcPos;
             dst[dstPos + i] = (byte) (0xff & (src >> shift));
         }
         return dst;
@@ -1241,9 +1222,8 @@ public class Conversion {
         if ((nBytes - 1) * 8 + srcPos >= 16) {
             throw new IllegalArgumentException("(nBytes-1)*8+srcPos is greather or equal to than 16");
         }
-        int shift = 0;
         for (int i = 0; i < nBytes; i++) {
-            shift = i * 8 + srcPos;
+            final int shift = i * 8 + srcPos;
             dst[dstPos + i] = (byte) (0xff & (src >> shift));
         }
         return dst;
@@ -1274,10 +1254,9 @@ public class Conversion {
             throw new IllegalArgumentException("(nHexs-1)*4+srcPos is greather or equal to than 64");
         }
         final StringBuilder sb = new StringBuilder(dstInit);
-        int shift = 0;
         int append = sb.length();
         for (int i = 0; i < nHexs; i++) {
-            shift = i * 4 + srcPos;
+            final int shift = i * 4 + srcPos;
             final int bits = (int) (0xF & (src >> shift));
             if (dstPos + i == append) {
                 ++append;
@@ -1314,10 +1293,9 @@ public class Conversion {
             throw new IllegalArgumentException("(nHexs-1)*4+srcPos is greather or equal to than 32");
         }
         final StringBuilder sb = new StringBuilder(dstInit);
-        int shift = 0;
         int append = sb.length();
         for (int i = 0; i < nHexs; i++) {
-            shift = i * 4 + srcPos;
+            final int shift = i * 4 + srcPos;
             final int bits = 0xF & (src >> shift);
             if (dstPos + i == append) {
                 ++append;
@@ -1354,10 +1332,9 @@ public class Conversion {
             throw new IllegalArgumentException("(nHexs-1)*4+srcPos is greather or equal to than 16");
         }
         final StringBuilder sb = new StringBuilder(dstInit);
-        int shift = 0;
         int append = sb.length();
         for (int i = 0; i < nHexs; i++) {
-            shift = i * 4 + srcPos;
+            final int shift = i * 4 + srcPos;
             final int bits = 0xF & (src >> shift);
             if (dstPos + i == append) {
                 ++append;
@@ -1394,10 +1371,9 @@ public class Conversion {
             throw new IllegalArgumentException("(nHexs-1)*4+srcPos is greather or equal to than 8");
         }
         final StringBuilder sb = new StringBuilder(dstInit);
-        int shift = 0;
         int append = sb.length();
         for (int i = 0; i < nHexs; i++) {
-            shift = i * 4 + srcPos;
+            final int shift = i * 4 + srcPos;
             final int bits = 0xF & (src >> shift);
             if (dstPos + i == append) {
                 ++append;
@@ -1434,9 +1410,8 @@ public class Conversion {
         if (nBools - 1 + srcPos >= 64) {
             throw new IllegalArgumentException("nBools-1+srcPos is greather or equal to than 64");
         }
-        int shift = 0;
         for (int i = 0; i < nBools; i++) {
-            shift = i + srcPos;
+            final int shift = i + srcPos;
             dst[dstPos + i] = (0x1 & (src >> shift)) != 0;
         }
         return dst;
@@ -1467,9 +1442,8 @@ public class Conversion {
         if (nBools - 1 + srcPos >= 32) {
             throw new IllegalArgumentException("nBools-1+srcPos is greather or equal to than 32");
         }
-        int shift = 0;
         for (int i = 0; i < nBools; i++) {
-            shift = i + srcPos;
+            final int shift = i + srcPos;
             dst[dstPos + i] = (0x1 & (src >> shift)) != 0;
         }
         return dst;
@@ -1500,10 +1474,9 @@ public class Conversion {
         if (nBools - 1 + srcPos >= 16) {
             throw new IllegalArgumentException("nBools-1+srcPos is greather or equal to than 16");
         }
-        int shift = 0;
         assert (nBools - 1) < 16 - srcPos;
         for (int i = 0; i < nBools; i++) {
-            shift = i + srcPos;
+            final int shift = i + srcPos;
             dst[dstPos + i] = (0x1 & (src >> shift)) != 0;
         }
         return dst;
@@ -1534,9 +1507,8 @@ public class Conversion {
         if (nBools - 1 + srcPos >= 8) {
             throw new IllegalArgumentException("nBools-1+srcPos is greather or equal to than 8");
         }
-        int shift = 0;
         for (int i = 0; i < nBools; i++) {
-            shift = i + srcPos;
+            final int shift = i + srcPos;
             dst[dstPos + i] = (0x1 & (src >> shift)) != 0;
         }
         return dst;