Skip to content

Commit 81a19e7

Browse files
author
MarcoFalke
committed
Merge #19852: refactor: Avoid duplicate map lookup in ScriptToAsmStr
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
2 parents df75e9f + ac2ff4f commit 81a19e7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/core_write.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDeco
111111
// checks in CheckSignatureEncoding.
112112
if (CheckSignatureEncoding(vch, SCRIPT_VERIFY_STRICTENC, nullptr)) {
113113
const unsigned char chSigHashType = vch.back();
114-
if (mapSigHashTypes.count(chSigHashType)) {
115-
strSigHashDecode = "[" + mapSigHashTypes.find(chSigHashType)->second + "]";
114+
const auto it = mapSigHashTypes.find(chSigHashType);
115+
if (it != mapSigHashTypes.end()) {
116+
strSigHashDecode = "[" + it->second + "]";
116117
vch.pop_back(); // remove the sighash type byte. it will be replaced by the decode.
117118
}
118119
}

0 commit comments

Comments
 (0)