8000 Use shifts for integer multiplications. · arduino/cbor-js@0838441 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0838441

Browse files
cynthiaparoga
authored andcommitted
Use shifts for integer multiplications.
1 parent 587cf48 commit 0838441

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cbor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ function encode(value) {
3737
var newByteLength = data.byteLength;
3838
var requiredLength = offset + length;
3939
while (newByteLength < requiredLength)
40-
newByteLength *= 2;
40+
newByteLength <<= 1;
4141
if (newByteLength !== data.byteLength) {
4242
var oldDataView = dataView;
4343
data = new ArrayBuffer(newByteLength);
4444
dataView = new DataView(data);
4545
var uint32count = (offset + 3) >> 2;
4646
for (var i = 0; i < uint32count; ++i)
47-
dataView.setUint32(i * 4, oldDataView.getUint32(i * 4));
47+
dataView.setUint32(i << 2, oldDataView.getUint32(i << 2));
4848
}
4949

5050
lastLength = length;

0 commit comments

Comments
 (0)
0