Prefer Array.prototype.slice over map

This commit is contained in:
Daniel Cousens 2014-04-18 06:19:47 +10:00
parent 669444cb10
commit 5adaa7dd54
2 changed files with 2 additions and 6 deletions

View file

@ -1201,9 +1201,7 @@ BigInteger.valueOf = nbv;
*/
BigInteger.fromByteArrayUnsigned = function(ba) {
// FIXME: BigInteger doesn't yet support Buffers
if (Buffer.isBuffer(ba)) {
ba = Array.prototype.map.bind(ba, function(x) { return x })()
}
if (Buffer.isBuffer(ba)) ba = Array.prototype.slice.call(ba)
if (!ba.length) {
return new BigInteger.valueOf(0);

View file

@ -339,9 +339,7 @@ Script.prototype.writeOp = function(opcode) {
*/
Script.prototype.writeBytes = function(data) {
// FIXME: Script module doesn't support buffers yet
if (Buffer.isBuffer(data)) {
data = Array.prototype.map.bind(data, function(x) { return x })()
}
if (Buffer.isBuffer(data)) data = Array.prototype.slice.call(data)
if (data.length < Opcode.map.OP_PUSHDATA1) {
this.buffer.push(data.length)