You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2018/04/12 14:00:08 UTC

qpid-proton-j git commit: PROTON-1672: replace use of Java 8+ constants

Repository: qpid-proton-j
Updated Branches:
  refs/heads/master ec5547152 -> 18d2cb369


PROTON-1672: replace use of Java 8+ constants


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/commit/18d2cb36
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/tree/18d2cb36
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/diff/18d2cb36

Branch: refs/heads/master
Commit: 18d2cb369a6d906b2cf8403184c7e35cd00ae7c0
Parents: ec55471
Author: Robbie Gemmell <ro...@apache.org>
Authored: Thu Apr 12 14:59:04 2018 +0100
Committer: Robbie Gemmell <ro...@apache.org>
Committed: Thu Apr 12 14:59:04 2018 +0100

----------------------------------------------------------------------
 .../qpid/proton/codec/CompositeReadableBuffer.java  | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/18d2cb36/proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeReadableBuffer.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeReadableBuffer.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeReadableBuffer.java
index e6652e4..fee963a 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeReadableBuffer.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/CompositeReadableBuffer.java
@@ -39,6 +39,10 @@ public class CompositeReadableBuffer implements ReadableBuffer {
     private static final CompositeReadableBuffer EMPTY_SLICE = new CompositeReadableBuffer(true);
     private static int UNSET_MARK = -1;
 
+    private static final int SHORT_BYTES = 2;
+    private static final int INT_BYTES = 4;
+    private static final int LONG_BYTES = 8;
+
     private ArrayList<byte[]> contents;
 
     // Track active array and our offset into it.
@@ -181,7 +185,7 @@ public class CompositeReadableBuffer implements ReadableBuffer {
 
     @Override
     public int getInt() {
-        if (remaining() < Integer.BYTES) {
+        if (remaining() < INT_BYTES) {
             throw new BufferUnderflowException();
         }
 
@@ -193,7 +197,7 @@ public class CompositeReadableBuffer implements ReadableBuffer {
                      (int)(currentArray[currentOffset++] & 0xFF) << 8 |
                      (int)(currentArray[currentOffset++] & 0xFF) << 0;
         } else {
-            for (int i = Integer.BYTES - 1; i >= 0; --i) {
+            for (int i = INT_BYTES - 1; i >= 0; --i) {
                 result |= (int)(currentArray[currentOffset++] & 0xFF) << (i * Byte.SIZE);
                 maybeMoveToNextArray();
             }
@@ -206,7 +210,7 @@ public class CompositeReadableBuffer implements ReadableBuffer {
 
     @Override
     public long getLong() {
-        if (remaining() < Long.BYTES) {
+        if (remaining() < LONG_BYTES) {
             throw new BufferUnderflowException();
         }
 
@@ -222,7 +226,7 @@ public class CompositeReadableBuffer implements ReadableBuffer {
                      (long)(currentArray[currentOffset++] & 0xFF) << 8 |
                      (long)(currentArray[currentOffset++] & 0xFF) << 0;
         } else {
-            for (int i = Long.BYTES - 1; i >= 0; --i) {
+            for (int i = LONG_BYTES - 1; i >= 0; --i) {
                 result |= (long)(currentArray[currentOffset++] & 0xFF) << (i * Byte.SIZE);
                 maybeMoveToNextArray();
             }
@@ -235,13 +239,13 @@ public class CompositeReadableBuffer implements ReadableBuffer {
 
     @Override
     public short getShort() {
-        if (remaining() < Short.BYTES) {
+        if (remaining() < SHORT_BYTES) {
             throw new BufferUnderflowException();
         }
 
         short result = 0;
 
-        for (int i = Short.BYTES - 1; i >= 0; --i) {
+        for (int i = SHORT_BYTES - 1; i >= 0; --i) {
             result |= (currentArray[currentOffset++] & 0xFF) << (i * Byte.SIZE);
             maybeMoveToNextArray();
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org