faster FindAndDelete.
This commit is contained in:
parent
e67a16c2bd
commit
51ebcf999b
@ -1972,6 +1972,44 @@ Script.array = function(value) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Script.prototype.removeData = function removeData(data) {
|
Script.prototype.removeData = function removeData(data) {
|
||||||
|
var index = [];
|
||||||
|
var i, op;
|
||||||
|
|
||||||
|
// We need to go forward first. We can't go
|
||||||
|
// backwards (this is consensus code and we
|
||||||
|
// need to be aware of bad pushes).
|
||||||
|
for (i = 0; i < this.code.length; i++) {
|
||||||
|
op = this.code[i];
|
||||||
|
|
||||||
|
if (Script.isBadPush(op))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!Buffer.isBuffer(op))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!Script.checkMinimal(op))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (utils.equal(op, data))
|
||||||
|
index.push(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index.length === 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Go backwards and splice out the data.
|
||||||
|
for (i = index.length - 1; i >= 0; i--)
|
||||||
|
this.code.splice(index[i], 1);
|
||||||
|
|
||||||
|
if (this.raw) {
|
||||||
|
delete this.raw;
|
||||||
|
this.encode();
|
||||||
|
}
|
||||||
|
|
||||||
|
return index.length;
|
||||||
|
};
|
||||||
|
|
||||||
|
Script.prototype.removeDataRaw = function removeDataRaw(data) {
|
||||||
var total = 0;
|
var total = 0;
|
||||||
var p, sig, raw, i, a, b, op, size;
|
var p, sig, raw, i, a, b, op, size;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user