Skip to content

Commit ac2ff4f

Browse files
committed
refactor: Avoid duplicate map lookup in ScriptToAsmStr
1 parent e796fdd commit ac2ff4f

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)