Project import generated by Copybara

PiperOrigin-RevId: 417622470
pull/9333/head
Mike Kruskal 3 years ago committed by Copybara-Service
parent 8f6c3c6824
commit b79dbb7db0
  1. 24
      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.

Loading…
Cancel
Save