| 556 | } |
| 557 | |
| 558 | int FindAndDelete(const CScript& b) |
| 559 | { |
| 560 | int nFound = 0; |
| 561 | if (b.empty()) |
| 562 | return nFound; |
| 563 | CScript result; |
| 564 | iterator pc = begin(), pc2 = begin(); |
| 565 | opcodetype opcode; |
| 566 | do |
| 567 | { |
| 568 | result.insert(result.end(), pc2, pc); |
| 569 | while (static_cast<size_t>(end() - pc) >= b.size() && std::equal(b.begin(), b.end(), pc)) |
| 570 | { |
| 571 | pc = pc + b.size(); |
| 572 | ++nFound; |
| 573 | } |
| 574 | pc2 = pc; |
| 575 | } |
| 576 | while (GetOp(pc, opcode)); |
| 577 | |
| 578 | if (nFound > 0) { |
| 579 | result.insert(result.end(), pc2, end()); |
| 580 | *this = result; |
| 581 | } |
| 582 | |
| 583 | return nFound; |
| 584 | } |
| 585 | int Find(opcodetype op) const |
| 586 | { |
| 587 | int nFound = 0; |