Skip to content

Commit

Permalink
Merge bitcoin#19852: refactor: Avoid duplicate map lookup in ScriptTo…
Browse files Browse the repository at this point in the history
…AsmStr

ac2ff4f refactor: Avoid duplicate map lookup in ScriptToAsmStr (João Barbosa)

Pull request description:

  Simple change that avoids a duplicate (unnecessary) `mapSigHashTypes` lookup.

ACKs for top commit:
  laanwj:
    re-ACK ac2ff4f

Tree-SHA512: 7e7f5af51c1acd7a42af273e5ee5e2faddd250ba8b8f63ccb3172d95f153ae391b2816b79564b856571af52dc2a767b5736a5d10ffb5cd2c540cd9832bf86419
  • Loading branch information
MarcoFalke authored and PastaPastaPasta committed Jun 28, 2021
1 parent 22c4ede commit 662c083
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDeco
// checks in CheckSignatureEncoding.
if (CheckSignatureEncoding(vch, SCRIPT_VERIFY_STRICTENC, nullptr)) {
const unsigned char chSigHashType = vch.back();
if (mapSigHashTypes.count(chSigHashType)) {
strSigHashDecode = "[" + mapSigHashTypes.find(chSigHashType)->second + "]";
const auto it = mapSigHashTypes.find(chSigHashType);
if (it != mapSigHashTypes.end()) {
strSigHashDecode = "[" + it->second + "]";
vch.pop_back(); // remove the sighash type byte. it will be replaced by the decode.
}
}
Expand Down

0 comments on commit 662c083

Please sign in to comment.