mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Use structured bindings in some places:
Most of the new uses either: * Replace some uses of `tie` * bind to pairs when iterating through maps
This commit is contained in:
@@ -295,10 +295,11 @@ int SField::compare (SField const& f1, SField const& f2)
|
||||
SField const&
|
||||
SField::getField (std::string const& fieldName)
|
||||
{
|
||||
for (auto const & fieldPair : knownCodeToField)
|
||||
for (auto const& [_, f] : knownCodeToField)
|
||||
{
|
||||
if (fieldPair.second->fieldName == fieldName)
|
||||
return * (fieldPair.second);
|
||||
(void)_;
|
||||
if (f->fieldName == fieldName)
|
||||
return *f;
|
||||
}
|
||||
return sfInvalid;
|
||||
}
|
||||
|
||||
@@ -477,13 +477,12 @@ static boost::optional<detail::STVar> parseLeaf (
|
||||
|
||||
try
|
||||
{
|
||||
std::pair<Blob, bool> vBlob (strUnHex (value.asString ()));
|
||||
auto [vBlob, validVBlob] = strUnHex (value.asString ());
|
||||
|
||||
if (! vBlob.second)
|
||||
if (! validVBlob)
|
||||
Throw<std::invalid_argument> ("invalid data");
|
||||
|
||||
ret = detail::make_stvar <STBlob> (field, vBlob.first.data (),
|
||||
vBlob.first.size ());
|
||||
ret = detail::make_stvar<STBlob>(field, vBlob.data(), vBlob.size());
|
||||
}
|
||||
catch (std::exception const&)
|
||||
{
|
||||
|
||||
@@ -428,9 +428,9 @@ isMemoOkay (STObject const& st, std::string& reason)
|
||||
}
|
||||
|
||||
// The raw data is stored as hex-octets, which we want to decode.
|
||||
auto data = strUnHex (memoElement.getText ());
|
||||
auto [data, validData] = strUnHex (memoElement.getText ());
|
||||
|
||||
if (!data.second)
|
||||
if (!validData)
|
||||
{
|
||||
reason = "The MemoType, MemoData and MemoFormat fields may "
|
||||
"only contain hex-encoded data.";
|
||||
@@ -459,7 +459,7 @@ isMemoOkay (STObject const& st, std::string& reason)
|
||||
return a;
|
||||
}();
|
||||
|
||||
for (auto c : data.first)
|
||||
for (auto c : data)
|
||||
{
|
||||
if (!allowedSymbols[c])
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user