Merge pull request #141 from dcousens/slicenotmap

Prefer Array.prototype.slice over map
This commit is contained in:
Wei Lu 2014-04-18 09:47:28 +08:00
commit f46780f25d
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)