lib/amq/protocol/table_value_decoder.rb in amq-protocol-1.9.1 vs lib/amq/protocol/table_value_decoder.rb in amq-protocol-1.9.2

- old
+ new

@@ -48,12 +48,12 @@ v, offset = decode_hash(data, offset) v when TYPE_BOOLEAN v, offset = decode_boolean(data, offset) v - when TYPE_SIGNED_8BIT then - v, offset = decode_short_short(data, offset) + when TYPE_BYTE then + v, offset = decode_byte(data, offset) v when TYPE_SIGNED_16BIT then v, offset = decode_short(data, offset) v when TYPE_SIGNED_64BIT then @@ -172,14 +172,18 @@ [v, offset] end # self.decode_hash(data, offset) - def self.decode_short_short(data, offset) - v = data.slice(offset, 1).unpack(PACK_INT8).first - offset += 1 - [v, offset] + # Decodes/Converts a byte value from the data at the provided offset. + # + # @param [Array] data - A big-endian ordered array of bytes. + # @param [Fixnum] offset - The offset which bytes the byte is consumed. + # @return [Array] - The Fixnum value and new offset pair. + def self.decode_byte(data, offset) + [data.slice(offset, 1).unpack(PACK_CHAR).first, offset += 1] end + def self.decode_short(data, offset) v = AMQ::Hacks.unpack_int16_big_endian(data.slice(offset, 2)).first offset += 2 [v, offset]