aboutsummaryrefslogtreecommitdiff
path: root/src/core_read.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-10-08 15:39:46 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-10-08 15:55:27 +0200
commitfa03dec7e98bdda8aa596ef7943cf0a8d0bcb127 (patch)
tree2b146cd5b928e183832812fac4cc636e76a80ea6 /src/core_read.cpp
parentfad55e79ca18a5894a8da6db6309c323eecbb178 (diff)
downloadbitcoin-fa03dec7e98bdda8aa596ef7943cf0a8d0bcb127.tar.xz
refactor: Use C++11 range based for loop in ParseScript
Diffstat (limited to 'src/core_read.cpp')
-rw-r--r--src/core_read.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/core_read.cpp b/src/core_read.cpp
index 320811b9e9..5effd49151 100644
--- a/src/core_read.cpp
+++ b/src/core_read.cpp
@@ -59,17 +59,17 @@ CScript ParseScript(const std::string& s)
std::vector<std::string> words;
boost::algorithm::split(words, s, boost::algorithm::is_any_of(" \t\n"), boost::algorithm::token_compress_on);
- for (std::vector<std::string>::const_iterator w = words.begin(); w != words.end(); ++w)
+ for (const std::string& w : words)
{
- if (w->empty())
+ if (w.empty())
{
// Empty string, ignore. (boost::split given '' will return one word)
}
- else if (std::all_of(w->begin(), w->end(), ::IsDigit) ||
- (w->front() == '-' && w->size() > 1 && std::all_of(w->begin()+1, w->end(), ::IsDigit)))
+ else if (std::all_of(w.begin(), w.end(), ::IsDigit) ||
+ (w.front() == '-' && w.size() > 1 && std::all_of(w.begin()+1, w.end(), ::IsDigit)))
{
// Number
- int64_t n = LocaleIndependentAtoi<int64_t>(*w);
+ int64_t n = LocaleIndependentAtoi<int64_t>(w);
//limit the range of numbers ParseScript accepts in decimal
//since numbers outside -0xFFFFFFFF...0xFFFFFFFF are illegal in scripts
@@ -80,23 +80,23 @@ CScript ParseScript(const std::string& s)
result << n;
}
- else if (w->substr(0,2) == "0x" && w->size() > 2 && IsHex(std::string(w->begin()+2, w->end())))
+ else if (w.substr(0,2) == "0x" && w.size() > 2 && IsHex(std::string(w.begin()+2, w.end())))
{
// Raw hex data, inserted NOT pushed onto stack:
- std::vector<unsigned char> raw = ParseHex(std::string(w->begin()+2, w->end()));
+ std::vector<unsigned char> raw = ParseHex(std::string(w.begin()+2, w.end()));
result.insert(result.end(), raw.begin(), raw.end());
}
- else if (w->size() >= 2 && w->front() == '\'' && w->back() == '\'')
+ else if (w.size() >= 2 && w.front() == '\'' && w.back() == '\'')
{
// Single-quoted string, pushed as data. NOTE: this is poor-man's
// parsing, spaces/tabs/newlines in single-quoted strings won't work.
- std::vector<unsigned char> value(w->begin()+1, w->end()-1);
+ std::vector<unsigned char> value(w.begin()+1, w.end()-1);
result << value;
}
else
{
// opcode, e.g. OP_ADD or ADD:
- result << ParseOpCode(*w);
+ result << ParseOpCode(w);
}
}