commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [2/2] commons-compress git commit: rename class constants that look like instance fields
Date Tue, 20 Dec 2016 14:12:45 GMT
rename class constants that look like instance fields


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/2b5ba89b
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/2b5ba89b
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/2b5ba89b

Branch: refs/heads/master
Commit: 2b5ba89b7705592e5ac2de46c6b68cfc5c16a53b
Parents: c61c68d
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Tue Dec 20 15:06:03 2016 +0100
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Tue Dec 20 15:06:03 2016 +0100

----------------------------------------------------------------------
 .../archivers/dump/TapeInputStream.java         | 24 ++++++------
 .../archivers/zip/StreamCompressor.java         |  6 +--
 .../compressors/snappy/PureJavaCrc32C.java      | 40 ++++++++++----------
 3 files changed, 35 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/2b5ba89b/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java
b/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java
index 0d6c694..b6f9f12 100644
--- a/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/dump/TapeInputStream.java
@@ -38,7 +38,7 @@ class TapeInputStream extends FilterInputStream {
     private byte[] blockBuffer = new byte[DumpArchiveConstants.TP_SIZE];
     private int currBlkIdx = -1;
     private int blockSize = DumpArchiveConstants.TP_SIZE;
-    private static final int recordSize = DumpArchiveConstants.TP_SIZE;
+    private static final int RECORD_SIZE = DumpArchiveConstants.TP_SIZE;
     private int readOffset = DumpArchiveConstants.TP_SIZE;
     private boolean isCompressed = false;
     private long bytesRead = 0;
@@ -68,18 +68,18 @@ class TapeInputStream extends FilterInputStream {
         throws IOException {
         this.isCompressed = isCompressed;
 
-        blockSize = recordSize * recsPerBlock;
+        blockSize = RECORD_SIZE * recsPerBlock;
 
         // save first block in case we need it again
         final byte[] oldBuffer = blockBuffer;
 
         // read rest of new block
         blockBuffer = new byte[blockSize];
-        System.arraycopy(oldBuffer, 0, blockBuffer, 0, recordSize);
-        readFully(blockBuffer, recordSize, blockSize - recordSize);
+        System.arraycopy(oldBuffer, 0, blockBuffer, 0, RECORD_SIZE);
+        readFully(blockBuffer, RECORD_SIZE, blockSize - RECORD_SIZE);
 
         this.currBlkIdx = 0;
-        this.readOffset = recordSize;
+        this.readOffset = RECORD_SIZE;
     }
 
     /**
@@ -100,7 +100,7 @@ class TapeInputStream extends FilterInputStream {
     @Override
     public int read() throws IOException {
         throw new IllegalArgumentException(
-            "all reads must be multiple of record size (" + recordSize +
+            "all reads must be multiple of record size (" + RECORD_SIZE +
             " bytes.");
     }
 
@@ -114,9 +114,9 @@ class TapeInputStream extends FilterInputStream {
      */
     @Override
     public int read(final byte[] b, int off, final int len) throws IOException {
-        if ((len % recordSize) != 0) {
+        if ((len % RECORD_SIZE) != 0) {
             throw new IllegalArgumentException(
-                "all reads must be multiple of record size (" + recordSize +
+                "all reads must be multiple of record size (" + RECORD_SIZE +
                 " bytes.");
         }
 
@@ -160,9 +160,9 @@ class TapeInputStream extends FilterInputStream {
      */
     @Override
     public long skip(final long len) throws IOException {
-        if ((len % recordSize) != 0) {
+        if ((len % RECORD_SIZE) != 0) {
             throw new IllegalArgumentException(
-                "all reads must be multiple of record size (" + recordSize +
+                "all reads must be multiple of record size (" + RECORD_SIZE +
                 " bytes.");
         }
 
@@ -223,7 +223,7 @@ class TapeInputStream extends FilterInputStream {
         }
 
         // copy data, increment counters.
-        final byte[] b = new byte[recordSize];
+        final byte[] b = new byte[RECORD_SIZE];
         System.arraycopy(blockBuffer, readOffset, b, 0, b.length);
 
         return b;
@@ -236,7 +236,7 @@ class TapeInputStream extends FilterInputStream {
      * @throws IOException on error
      */
     public byte[] readRecord() throws IOException {
-        final byte[] result = new byte[recordSize];
+        final byte[] result = new byte[RECORD_SIZE];
 
         // the read implementation will loop internally as long as
         // input is available

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/2b5ba89b/src/main/java/org/apache/commons/compress/archivers/zip/StreamCompressor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/StreamCompressor.java
b/src/main/java/org/apache/commons/compress/archivers/zip/StreamCompressor.java
index 218f54a..1e8d68b 100644
--- a/src/main/java/org/apache/commons/compress/archivers/zip/StreamCompressor.java
+++ b/src/main/java/org/apache/commons/compress/archivers/zip/StreamCompressor.java
@@ -56,9 +56,9 @@ public abstract class StreamCompressor implements Closeable {
     private long sourcePayloadLength = 0;
     private long totalWrittenToOutputStream = 0;
 
-    private static final int bufferSize = 4096;
-    private final byte[] outputBuffer = new byte[bufferSize];
-    private final byte[] readerBuf = new byte[bufferSize];
+    private static final int BUFFER_SIZE = 4096;
+    private final byte[] outputBuffer = new byte[BUFFER_SIZE];
+    private final byte[] readerBuf = new byte[BUFFER_SIZE];
 
     StreamCompressor(final Deflater deflater) {
         this.def = deflater;

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/2b5ba89b/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java
b/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java
index 6f216ff..9ef2701 100644
--- a/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java
+++ b/src/main/java/org/apache/commons/compress/compressors/snappy/PureJavaCrc32C.java
@@ -63,16 +63,16 @@ final class PureJavaCrc32C implements Checksum {
       final int c1 =(b[off+1] ^ (localCrc >>>= 8)) & 0xff; //NOSONAR
       final int c2 =(b[off+2] ^ (localCrc >>>= 8)) & 0xff; //NOSONAR
       final int c3 =(b[off+3] ^ (localCrc >>>= 8)) & 0xff; //NOSONAR
-      localCrc = (T[T8_7_start + c0] ^ T[T8_6_start + c1])
-          ^ (T[T8_5_start + c2] ^ T[T8_4_start + c3]);
+      localCrc = (T[T8_7_START + c0] ^ T[T8_6_START + c1])
+          ^ (T[T8_5_START + c2] ^ T[T8_4_START + c3]);
 
       final int c4 = b[off+4] & 0xff;
       final int c5 = b[off+5] & 0xff;
       final int c6 = b[off+6] & 0xff;
       final int c7 = b[off+7] & 0xff;
 
-      localCrc ^= (T[T8_3_start + c4] ^ T[T8_2_start + c5])
-           ^ (T[T8_1_start + c6] ^ T[T8_0_start + c7]);
+      localCrc ^= (T[T8_3_START + c4] ^ T[T8_2_START + c5])
+           ^ (T[T8_1_START + c6] ^ T[T8_0_START + c7]);
 
       off += 8;
       len -= 8;
@@ -80,13 +80,13 @@ final class PureJavaCrc32C implements Checksum {
 
     /* loop unroll - duff's device style */
     switch(len) {
-      case 7: localCrc = (localCrc >>> 8) ^ T[T8_0_start + ((localCrc ^ b[off++])
& 0xff)];
-      case 6: localCrc = (localCrc >>> 8) ^ T[T8_0_start + ((localCrc ^ b[off++])
& 0xff)];
-      case 5: localCrc = (localCrc >>> 8) ^ T[T8_0_start + ((localCrc ^ b[off++])
& 0xff)];
-      case 4: localCrc = (localCrc >>> 8) ^ T[T8_0_start + ((localCrc ^ b[off++])
& 0xff)];
-      case 3: localCrc = (localCrc >>> 8) ^ T[T8_0_start + ((localCrc ^ b[off++])
& 0xff)];
-      case 2: localCrc = (localCrc >>> 8) ^ T[T8_0_start + ((localCrc ^ b[off++])
& 0xff)];
-      case 1: localCrc = (localCrc >>> 8) ^ T[T8_0_start + ((localCrc ^ b[off++])
& 0xff)];
+      case 7: localCrc = (localCrc >>> 8) ^ T[T8_0_START + ((localCrc ^ b[off++])
& 0xff)];
+      case 6: localCrc = (localCrc >>> 8) ^ T[T8_0_START + ((localCrc ^ b[off++])
& 0xff)];
+      case 5: localCrc = (localCrc >>> 8) ^ T[T8_0_START + ((localCrc ^ b[off++])
& 0xff)];
+      case 4: localCrc = (localCrc >>> 8) ^ T[T8_0_START + ((localCrc ^ b[off++])
& 0xff)];
+      case 3: localCrc = (localCrc >>> 8) ^ T[T8_0_START + ((localCrc ^ b[off++])
& 0xff)];
+      case 2: localCrc = (localCrc >>> 8) ^ T[T8_0_START + ((localCrc ^ b[off++])
& 0xff)];
+      case 1: localCrc = (localCrc >>> 8) ^ T[T8_0_START + ((localCrc ^ b[off++])
& 0xff)];
       default:
         /* nothing */
     }
@@ -97,21 +97,21 @@ final class PureJavaCrc32C implements Checksum {
 
   @Override
   final public void update(final int b) {
-    crc = (crc >>> 8) ^ T[T8_0_start + ((crc ^ b) & 0xff)];
+    crc = (crc >>> 8) ^ T[T8_0_START + ((crc ^ b) & 0xff)];
   }
     
   // CRC polynomial tables generated by:
   // java -cp build/test/classes/:build/classes/ \
   //   org.apache.hadoop.util.TestPureJavaCrc32\$Table 82F63B78
 
-  private static final int T8_0_start = 0*256;
-  private static final int T8_1_start = 1*256;
-  private static final int T8_2_start = 2*256;
-  private static final int T8_3_start = 3*256;
-  private static final int T8_4_start = 4*256;
-  private static final int T8_5_start = 5*256;
-  private static final int T8_6_start = 6*256;
-  private static final int T8_7_start = 7*256;
+  private static final int T8_0_START = 0*256;
+  private static final int T8_1_START = 1*256;
+  private static final int T8_2_START = 2*256;
+  private static final int T8_3_START = 3*256;
+  private static final int T8_4_START = 4*256;
+  private static final int T8_5_START = 5*256;
+  private static final int T8_6_START = 6*256;
+  private static final int T8_7_START = 7*256;
 
   private static final int[] T = new int[] {
     /* T8_0 */


Mime
View raw message