diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-09-05 13:43:33 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-09-05 13:43:36 +0200 |
commit | 81a19e725304bc77c39491f312913b47b76a6dac (patch) | |
tree | 032b761233500a6fc79c9716619495095a2aea27 | |
parent | df75e9f3ee4de2b841fe0e84514b58a4e630d258 (diff) | |
parent | ac2ff4fb1e06270cf17727f90599c9f3a55ddd5a (diff) |
Merge #19852: refactor: Avoid duplicate map lookup in ScriptToAsmStr
ac2ff4fb1e06270cf17727f90599c9f3a55ddd5a 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 ac2ff4fb1e06270cf17727f90599c9f3a55ddd5a
Tree-SHA512: 7e7f5af51c1acd7a42af273e5ee5e2faddd250ba8b8f63ccb3172d95f153ae391b2816b79564b856571af52dc2a767b5736a5d10ffb5cd2c540cd9832bf86419
-rw-r--r-- | src/core_write.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/core_write.cpp b/src/core_write.cpp index f9d918cb6d..3980d8cb2e 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -111,8 +111,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. } } |