Skip to content

Commit 7b8e19e

Browse files
authored
Merge pull request #9333 from protocolbuffers/test_417622470
Project import generated by Copybara
2 parents a4f08b9 + 911d932 commit 7b8e19e

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

experimental/runtime/kernel/reader.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,6 @@ function readSfixed64(bufferDecoder, start) {
9797
return Int64.fromBits(lowBits, highBits);
9898
}
9999

100-
/**
101-
* Reads a sint32 value from the binary bytes encoded as varint.
102-
* @param {!BufferDecoder} bufferDecoder Binary format encoded bytes.
103-
* @param {number} start Start of the data.
104-
* @return {number}
105-
* @package
106-
*/
107-
function readSint32(bufferDecoder, start) {
108-
const bits = bufferDecoder.getUnsignedVarint32At(start);
109-
// Truncate upper bits and convert from zig zag to signd int
110-
return (bits >>> 1) ^ -(bits & 0x01);
111-
}
112-
113100
/**
114101
* Reads a sint64 value from the binary bytes encoded as varint.
115102
* @param {!BufferDecoder} bufferDecoder Binary format encoded bytes.
@@ -125,6 +112,17 @@ function readSint64(bufferDecoder, start) {
125112
return Int64.fromBits(decodedLowerBits, decodedUpperBits);
126113
}
127114

115+
/**
116+
* Reads a sint32 value from the binary bytes encoded as varint.
117+
* @param {!BufferDecoder} bufferDecoder Binary format encoded bytes.
118+
* @param {number} start Start of the data.
119+
* @return {number}
120+
* @package
121+
*/
122+
function readSint32(bufferDecoder, start) {
123+
return readSint64(bufferDecoder, start).getLowBits();
124+
}
125+
128126
/**
129127
* Read a subarray of bytes representing a length delimited field.
130128
* @param {!BufferDecoder} bufferDecoder Binary format encoded bytes.

0 commit comments

Comments
 (0)