Skip to content

Commit

Permalink
Fix reverse()
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Nov 10, 2013
1 parent 23310da commit fc5590f
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
11 changes: 6 additions & 5 deletions ByteBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@
var o = this.offset;
this.offset = this.array.byteLength - this.length;
this.length = this.array.byteLength - o;
this.view = new DataView(this.array);
return this;
};

Expand Down Expand Up @@ -1071,11 +1072,11 @@
offset = typeof offset !== 'undefined' ? offset : this.offset;
// ref: src/google/protobuf/io/coded_stream.cc

var count = 0,
b;
var count = 0, b,
src = this.view;
var value = 0 >>> 0;
do {
b = this.view.getUint8(offset+count);
b = src.getUint8(offset+count);
if (count < ByteBuffer.MAX_VARINT32_BYTES) {
value |= ((b&0x7F)<<(7*count)) >>> 0;
}
Expand Down Expand Up @@ -2001,13 +2002,13 @@
asArray = !!asArray;
wrap = typeof wrap !== 'undefined' ? parseInt(wrap, 10) : 16;
if (wrap < 1) wrap = 16;
var out = "", lines = [];
var out = "", lines = [], src = this.view;
for (var i=0; i<this.array.byteLength; i++) {
if (i>0 && i%wrap == 0) {
lines.push(out);
out = "";
}
var val = this.view.getUint8(i);
var val = src.getUint8(i);
if (val > 32 && val < 127) {
val = String.fromCharCode(val);
} else {
Expand Down
Loading

0 comments on commit fc5590f

Please sign in to comment.