Skip to content

Commit fc5590f

Browse files
committed
Fix reverse()
1 parent 23310da commit fc5590f

File tree

6 files changed

+31
-28
lines changed

6 files changed

+31
-28
lines changed

ByteBuffer.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@
469469
var o = this.offset;
470470
this.offset = this.array.byteLength - this.length;
471471
this.length = this.array.byteLength - o;
472+
this.view = new DataView(this.array);
472473
return this;
473474
};
474475

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

1074-
var count = 0,
1075-
b;
1075+
var count = 0, b,
1076+
src = this.view;
10761077
var value = 0 >>> 0;
10771078
do {
1078-
b = this.view.getUint8(offset+count);
1079+
b = src.getUint8(offset+count);
10791080
if (count < ByteBuffer.MAX_VARINT32_BYTES) {
10801081
value |= ((b&0x7F)<<(7*count)) >>> 0;
10811082
}
@@ -2001,13 +2002,13 @@
20012002
asArray = !!asArray;
20022003
wrap = typeof wrap !== 'undefined' ? parseInt(wrap, 10) : 16;
20032004
if (wrap < 1) wrap = 16;
2004-
var out = "", lines = [];
2005+
var out = "", lines = [], src = this.view;
20052006
for (var i=0; i<this.array.byteLength; i++) {
20062007
if (i>0 && i%wrap == 0) {
20072008
lines.push(out);
20082009
out = "";
20092010
}
2010-
var val = this.view.getUint8(i);
2011+
var val = src.getUint8(i);
20112012
if (val > 32 && val < 127) {
20122013
val = String.fromCharCode(val);
20132014
} else {

0 commit comments

Comments
 (0)