PROTON-1708: simplify the look-ahead for list entry types
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/codec/ListType.java b/proton-j/src/main/java/org/apache/qpid/proton/codec/ListType.java
index 67e9d6e..ba84141 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/codec/ListType.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/codec/ListType.java
@@ -168,8 +168,8 @@
             for (int i = 0; i < count; i++)
             {
                 boolean arrayType = false;
-                byte code = buffer.get(buffer.position());
-                switch (code)
+                byte encodingCode = buffer.get(buffer.position());
+                switch (encodingCode)
                 {
                     case EncodingCodes.ARRAY8:
                     case EncodingCodes.ARRAY32:
@@ -184,12 +184,8 @@
                 }
                 else
                 {
-                    buffer.mark();
-
-                    byte encodingCode = buffer.get();
                     if (encodingCode == EncodingCodes.DESCRIBED_TYPE_INDICATOR || !(typeConstructor instanceof PrimitiveTypeEncoding<?>))
                     {
-                        buffer.reset();
                         typeConstructor = getDecoder().readConstructor();
                     }
                     else
@@ -197,9 +193,13 @@
                         PrimitiveTypeEncoding<?> primitiveConstructor = (PrimitiveTypeEncoding<?>) typeConstructor;
                         if (encodingCode != primitiveConstructor.getEncodingCode())
                         {
-                            buffer.reset();
                             typeConstructor = getDecoder().readConstructor();
                         }
+                        else
+                        {
+                            // consume the encoding code byte for real
+                            encodingCode = buffer.get();
+                        }
                     }
                 }
 
@@ -307,8 +307,8 @@
             for (int i = 0; i < count; i++)
             {
                 boolean arrayType = false;
-                byte code = buffer.get(buffer.position());
-                switch (code)
+                byte encodingCode = buffer.get(buffer.position());
+                switch (encodingCode)
                 {
                     case EncodingCodes.ARRAY8:
                     case EncodingCodes.ARRAY32:
@@ -323,12 +323,8 @@
                 }
                 else
                 {
-                    buffer.mark();
-
-                    byte encodingCode = buffer.get();
                     if (encodingCode == EncodingCodes.DESCRIBED_TYPE_INDICATOR || !(typeConstructor instanceof PrimitiveTypeEncoding<?>))
                     {
-                        buffer.reset();
                         typeConstructor = getDecoder().readConstructor();
                     }
                     else
@@ -336,9 +332,13 @@
                         PrimitiveTypeEncoding<?> primitiveConstructor = (PrimitiveTypeEncoding<?>) typeConstructor;
                         if (encodingCode != primitiveConstructor.getEncodingCode())
                         {
-                            buffer.reset();
                             typeConstructor = getDecoder().readConstructor();
                         }
+                        else
+                        {
+                            // consume the encoding code byte for real
+                            encodingCode = buffer.get();
+                        }
                     }
                 }