Skip to content

Commit 65ed198

Browse files
committed
wallet: refactor: inline function ReadOrderPos()
Since accounts were removed in commit c9c32e6, this function is only called at one place and thus can be as well inlined. Also, avoid a duplicate lookup by using the find() method and dereference, instead of calling count() and operator[].
1 parent 053a5fc commit 65ed198

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/wallet/transaction.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,6 @@
2020
typedef std::map<std::string, std::string> mapValue_t;
2121

2222

23-
static inline void ReadOrderPos(int64_t& nOrderPos, mapValue_t& mapValue)
24-
{
25-
if (!mapValue.count("n"))
26-
{
27-
nOrderPos = -1; // TODO: calculate elsewhere
28-
return;
29-
}
30-
nOrderPos = atoi64(mapValue["n"]);
31-
}
32-
33-
3423
static inline void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue)
3524
{
3625
if (nOrderPos == -1)
@@ -232,7 +221,8 @@ class CWalletTx
232221
setConfirmed();
233222
}
234223

235-
ReadOrderPos(nOrderPos, mapValue);
224+
const auto it_op = mapValue.find("n");
225+
nOrderPos = (it_op != mapValue.end()) ? atoi64(it_op->second) : -1;
236226
nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(mapValue["timesmart"]) : 0;
237227

238228
mapValue.erase("fromaccount");

0 commit comments

Comments
 (0)