aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoão Barbosa <[email protected]>2020-08-31 22:11:06 +0100
committerJoão Barbosa <[email protected]>2020-09-04 10:25:44 +0100
commitac2ff4fb1e06270cf17727f90599c9f3a55ddd5a (patch)
tree63c3bc44733b7a04c1dc4dde9c35c2f77a2d78a2 /src
parentMerge #19507: Expand functional zmq transaction tests (diff)
downloaddiscoin-ac2ff4fb1e06270cf17727f90599c9f3a55ddd5a.tar.xz
discoin-ac2ff4fb1e06270cf17727f90599c9f3a55ddd5a.zip
refactor: Avoid duplicate map lookup in ScriptToAsmStr
Diffstat (limited to 'src')
-rw-r--r--src/core_write.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/core_write.cpp b/src/core_write.cpp
index f9d918cb6..3980d8cb2 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.
}
}