Skip to content

Commit f46780f

Browse files
committed
Merge pull request bitcoinjs#141 from dcousens/slicenotmap
Prefer Array.prototype.slice over map
2 parents 669444c + 5adaa7d commit f46780f

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/jsbn/jsbn.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,9 +1201,7 @@ BigInteger.valueOf = nbv;
12011201
*/
12021202
BigInteger.fromByteArrayUnsigned = function(ba) {
12031203
// FIXME: BigInteger doesn't yet support Buffers
1204-
if (Buffer.isBuffer(ba)) {
1205-
ba = Array.prototype.map.bind(ba, function(x) { return x })()
1206-
}
1204+
if (Buffer.isBuffer(ba)) ba = Array.prototype.slice.call(ba)
12071205

12081206
if (!ba.length) {
12091207
return new BigInteger.valueOf(0);

src/script.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,7 @@ Script.prototype.writeOp = function(opcode) {
339339
*/
340340
Script.prototype.writeBytes = function(data) {
341341
// FIXME: Script module doesn't support buffers yet
342-
if (Buffer.isBuffer(data)) {
343-
data = Array.prototype.map.bind(data, function(x) { return x })()
344-
}
342+
if (Buffer.isBuffer(data)) data = Array.prototype.slice.call(data)
345343

346344
if (data.length < Opcode.map.OP_PUSHDATA1) {
347345
this.buffer.push(data.length)

0 commit comments

Comments
 (0)