diff --git a/js/experimental/runtime/kernel/reader.js b/js/experimental/runtime/kernel/reader.js index 2b80e15bff..44708b5aec 100644 --- a/js/experimental/runtime/kernel/reader.js +++ b/js/experimental/runtime/kernel/reader.js @@ -97,19 +97,6 @@ function readSfixed64(bufferDecoder, start) { return Int64.fromBits(lowBits, highBits); } -/** - * Reads a sint32 value from the binary bytes encoded as varint. - * @param {!BufferDecoder} bufferDecoder Binary format encoded bytes. - * @param {number} start Start of the data. - * @return {number} - * @package - */ -function readSint32(bufferDecoder, start) { - const bits = bufferDecoder.getUnsignedVarint32At(start); - // Truncate upper bits and convert from zig zag to signd int - return (bits >>> 1) ^ -(bits & 0x01); -} - /** * Reads a sint64 value from the binary bytes encoded as varint. * @param {!BufferDecoder} bufferDecoder Binary format encoded bytes. @@ -125,6 +112,17 @@ function readSint64(bufferDecoder, start) { return Int64.fromBits(decodedLowerBits, decodedUpperBits); } +/** + * Reads a sint32 value from the binary bytes encoded as varint. + * @param {!BufferDecoder} bufferDecoder Binary format encoded bytes. + * @param {number} start Start of the data. + * @return {number} + * @package + */ +function readSint32(bufferDecoder, start) { + return readSint64(bufferDecoder, start).getLowBits(); +} + /** * Read a subarray of bytes representing a length delimited field. * @param {!BufferDecoder} bufferDecoder Binary format encoded bytes.