qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject qpid-proton-j git commit: PROTON-1708 Reduce overhead of reading zero sized values
Date Mon, 04 Dec 2017 19:04:21 GMT
Repository: qpid-proton-j
Updated Branches:
  refs/heads/master 2a2d3ff27 -> 972dddc99


PROTON-1708 Reduce overhead of reading zero sized values

For types that carry no payload for the value, reduce the call tree by
returing the type directly instead of looking up the encoding and
calling into it for the default value.  This also remove some
auto-boxing that was being done in the readBoolean case for the decoder.

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/972dddc9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/tree/972dddc9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton-j/diff/972dddc9

Branch: refs/heads/master
Commit: 972dddc99f21eb70ce7cc371b2a50c9be260b18d
Parents: 2a2d3ff
Author: Timothy Bish <tabish121@gmail.com>
Authored: Mon Dec 4 14:03:52 2017 -0500
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Mon Dec 4 14:03:52 2017 -0500

----------------------------------------------------------------------
 .../org/apache/qpid/proton/codec/DecoderImpl.java     | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/972dddc9/proton-j/src/main/java/org/apache/qpid/proton/codec/DecoderImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/DecoderImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/DecoderImpl.java
index 1763129..c305916 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/DecoderImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/DecoderImpl.java
@@ -170,9 +170,9 @@ public class DecoderImpl implements ByteBufferDecoder
         switch (encodingCode)
         {
             case EncodingCodes.BOOLEAN_TRUE:
-                return (Boolean) _constructors[EncodingCodes.BOOLEAN_TRUE & 0xff].readValue();
+                return Boolean.TRUE;
             case EncodingCodes.BOOLEAN_FALSE:
-                return (Boolean) _constructors[EncodingCodes.BOOLEAN_FALSE & 0xff].readValue();
+                return Boolean.FALSE;
             case EncodingCodes.BOOLEAN:
                 return (Boolean) _constructors[EncodingCodes.BOOLEAN & 0xff].readValue();
             case EncodingCodes.NULL:
@@ -189,9 +189,9 @@ public class DecoderImpl implements ByteBufferDecoder
         switch (encodingCode)
         {
             case EncodingCodes.BOOLEAN_TRUE:
-                return (Boolean) _constructors[EncodingCodes.BOOLEAN_TRUE & 0xff].readValue();
+                return true;
             case EncodingCodes.BOOLEAN_FALSE:
-                return (Boolean) _constructors[EncodingCodes.BOOLEAN_FALSE & 0xff].readValue();
+                return false;
             case EncodingCodes.BOOLEAN:
                 return (Boolean) _constructors[EncodingCodes.BOOLEAN & 0xff].readValue();
             case EncodingCodes.NULL:
@@ -423,7 +423,7 @@ public class DecoderImpl implements ByteBufferDecoder
         switch (encodingCode)
         {
             case EncodingCodes.UINT0:
-                return (UnsignedInteger) _constructors[EncodingCodes.UINT0 & 0xff].readValue();
+                return UnsignedInteger.ZERO;
             case EncodingCodes.SMALLUINT:
                 return (UnsignedInteger) _constructors[EncodingCodes.SMALLUINT & 0xff].readValue();
             case EncodingCodes.UINT:
@@ -447,7 +447,7 @@ public class DecoderImpl implements ByteBufferDecoder
         switch (encodingCode)
         {
             case EncodingCodes.ULONG0:
-                return (UnsignedLong) _constructors[EncodingCodes.ULONG0 & 0xff].readValue();
+                return UnsignedLong.ZERO;
             case EncodingCodes.SMALLULONG:
                 return (UnsignedLong) _constructors[EncodingCodes.SMALLULONG & 0xff].readValue();
             case EncodingCodes.ULONG:
@@ -752,7 +752,7 @@ public class DecoderImpl implements ByteBufferDecoder
         switch (encodingCode)
         {
             case EncodingCodes.LIST0:
-                return (List) _constructors[EncodingCodes.LIST0 & 0xff].readValue();
+                return Collections.EMPTY_LIST;
             case EncodingCodes.LIST8:
                 return (List) _constructors[EncodingCodes.LIST8 & 0xff].readValue();
             case EncodingCodes.LIST32:


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


Mime
View raw message