Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.cpp
Show First 20 Lines • Show All 791 Lines • ▼ Show 20 Lines | try { | ||||
// throw error if inputs are not the same size | // throw error if inputs are not the same size | ||||
if (vch1.size() != vch2.size()) { | if (vch1.size() != vch2.size()) { | ||||
return set_error( | return set_error( | ||||
serror, SCRIPT_ERR_INVALID_BITWISE_OPERATION); | serror, SCRIPT_ERR_INVALID_BITWISE_OPERATION); | ||||
} | } | ||||
switch (opcode) { | switch (opcode) { | ||||
case OP_AND: | case OP_AND: | ||||
for (size_t i = 0; i < vch1.size(); i++) { | for (auto it = vch1.begin(); it != vch1.end(); ++it) { | ||||
schancel: I think I prefer the older syntax here. The other option would be to use some kind of zip… | |||||
vch1[i] &= vch2[i]; | auto i = std::distance(vch1.begin(), it); | ||||
*it &= vch2[i]; | |||||
} | } | ||||
break; | break; | ||||
case OP_OR: | case OP_OR: | ||||
for (size_t i = 0; i < vch1.size(); i++) { | for (auto it = vch1.begin(); it != vch1.end(); ++it) { | ||||
vch1[i] |= vch2[i]; | auto i = std::distance(vch1.begin(), it); | ||||
*it |= vch2[i]; | |||||
} | } | ||||
break; | break; | ||||
case OP_XOR: | case OP_XOR: | ||||
for (size_t i = 0; i < vch1.size(); i++) { | for (auto it = vch1.begin(); it != vch1.end(); ++it) { | ||||
vch1[i] ^= vch2[i]; | auto i = std::distance(vch1.begin(), it); | ||||
*it ^= vch2[i]; | |||||
} | } | ||||
break; | break; | ||||
} | } | ||||
stack.pop_back(); | stack.pop_back(); | ||||
} break; | } break; | ||||
case OP_EQUAL: | case OP_EQUAL: | ||||
case OP_EQUALVERIFY: | case OP_EQUALVERIFY: | ||||
▲ Show 20 Lines • Show All 842 Lines • Show Last 20 Lines |
I think I prefer the older syntax here. The other option would be to use some kind of zip operation, but I don't see a conveniently available one.