Skip to content

Commit

Permalink
optimize buffered transport.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anlv.Tan committed Oct 27, 2014
1 parent cd725ec commit 8eadec0
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/thrift/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,11 @@ TBufferedTransport.receiver = function(callback) {
TBufferedTransport.prototype = {
commitPosition: function(){
var unreadedSize = this.writeCursor - this.readCursor;
var bufSize = (unreadedSize * 2 > this.defaultReadBufferSize) ? unreadedSize * 2 : this.defaultReadBufferSize;
var buf = new Buffer(bufSize);
if (unreadedSize > 0) {
this.inBuf.copy(buf, 0, this.readCursor, this.writeCursor);
this.inBuf.copy(this.inBuf, 0, this.readCursor, this.writeCursor);
}
this.readCursor = 0;
this.writeCursor = unreadedSize;
this.inBuf = buf;
},
rollbackPosition: function(){
this.readCursor = 0;
Expand Down

0 comments on commit 8eadec0

Please sign in to comment.