Skip to content

Commit cada370

Browse files
THRIFT-3048: Repair node i64 compact interface
Client: Node lib Patch: Will Demaine Github Pull Request: This closes apache#403 commit 11d0a66 Author: Willyham <willyd@uber.com> Date: 2015-03-20T22:28:01Z Make TCompactProtocol always return an object for i64
1 parent 41ad434 commit cada370

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

lib/nodejs/lib/thrift/compact_protocol.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ TCompactProtocol.prototype.readString = function() {
780780
* if there is another byte to follow. This can read up to 5 bytes.
781781
*/
782782
TCompactProtocol.prototype.readVarint32 = function() {
783-
return this.readVarint64();
783+
return this.readVarint64().toNumber();
784784
};
785785

786786
/**
@@ -811,8 +811,7 @@ TCompactProtocol.prototype.readVarint64 = function() {
811811
throw new Thrift.TProtocolException(Thrift.TProtocolExceptionType.INVALID_DATA, "Variable-length int over 10 bytes.");
812812
}
813813
}
814-
var i64 = new Int64(hi, lo);
815-
return i64.toNumber();
814+
return new Int64(hi, lo);
816815
};
817816

818817
/**
@@ -826,9 +825,8 @@ TCompactProtocol.prototype.zigzagToI32 = function(n) {
826825
* Convert from zigzag long to long.
827826
*/
828827
TCompactProtocol.prototype.zigzagToI64 = function(n) {
829-
var zz = new Int64(n);
830-
var hi = zz.buffer.readUInt32BE(0, true);
831-
var lo = zz.buffer.readUInt32BE(4, true);
828+
var hi = n.buffer.readUInt32BE(0, true);
829+
var lo = n.buffer.readUInt32BE(4, true);
832830

833831
var neg = new Int64(hi & 0, lo & 1);
834832
neg._2scomp();
@@ -838,8 +836,7 @@ TCompactProtocol.prototype.zigzagToI64 = function(n) {
838836
var hi_lo = (hi << 31);
839837
hi = (hi >>> 1) ^ (hi_neg);
840838
lo = ((lo >>> 1) | hi_lo) ^ (lo_neg);
841-
var i64 = new Int64(hi, lo);
842-
return i64.toNumber();
839+
return new Int64(hi, lo);
843840
};
844841

845842
TCompactProtocol.prototype.skip = function(type) {

0 commit comments

Comments
 (0)