Skip to content

Commit 1668c80

Browse files
committed
Merge #18449: util: Remove unused itostr
faaf1cb util: Replace i64tostr with ToString (MarcoFalke) fac96ff util: Remove unused itostr (MarcoFalke) Pull request description: Currently unused, but if someone really needed to use a helper with this functionality in the future, they could use `ToString`. ACKs for top commit: laanwj: ACK faaf1cb promag: Code review ACK faaf1cb. Tree-SHA512: 42180c03f51d677f7b69da23c7868bdd88944335fad0752fcc307f2c3e3c69f1cc1b316ac0875bcefb9a69c5d55200d7cf66843ea4c0f0f26baf7a054b96c1bb
2 parents 1277ca4 + faaf1cb commit 1668c80

File tree

7 files changed

+14
-26
lines changed

7 files changed

+14
-26
lines changed

src/rpc/mining.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <univalue.h>
2828
#include <util/fees.h>
2929
#include <util/strencodings.h>
30+
#include <util/string.h>
3031
#include <util/system.h>
3132
#include <validation.h>
3233
#include <validationinterface.h>
@@ -694,7 +695,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
694695
result.pushKV("transactions", transactions);
695696
result.pushKV("coinbaseaux", aux);
696697
result.pushKV("coinbasevalue", (int64_t)pblock->vtx[0]->vout[0].nValue);
697-
result.pushKV("longpollid", ::ChainActive().Tip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast));
698+
result.pushKV("longpollid", ::ChainActive().Tip()->GetBlockHash().GetHex() + ToString(nTransactionsUpdatedLast));
698699
result.pushKV("target", hashTarget.GetHex());
699700
result.pushKV("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1);
700701
result.pushKV("mutable", aMutable);

src/sync.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#include <util/strencodings.h>
1414
#include <util/threadnames.h>
1515

16-
#include <system_error>
1716
#include <map>
1817
#include <set>
18+
#include <system_error>
1919

2020
#ifdef DEBUG_LOCKCONTENTION
2121
#if !defined(HAVE_THREAD_LOCAL)
@@ -57,7 +57,7 @@ struct CLockLocation {
5757
{
5858
return strprintf(
5959
"%s %s:%s%s (in thread %s)",
60-
mutexName, sourceFile, itostr(sourceLine), (fTry ? " (TRY)" : ""), m_thread_name);
60+
mutexName, sourceFile, sourceLine, (fTry ? " (TRY)" : ""), m_thread_name);
6161
}
6262

6363
std::string Name() const

src/test/fuzz/integer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <uint256.h>
2828
#include <util/moneystr.h>
2929
#include <util/strencodings.h>
30+
#include <util/string.h>
3031
#include <util/system.h>
3132
#include <util/time.h>
3233
#include <version.h>
@@ -93,11 +94,10 @@ void test_one_input(const std::vector<uint8_t>& buffer)
9394
// (void)GetVirtualTransactionSize(i64, i64, u32); // function defined only for a subset of int64_t/uint32_t inputs
9495
(void)HexDigit(ch);
9596
(void)MoneyRange(i64);
96-
(void)i64tostr(i64);
97+
(void)ToString(i64);
9798
(void)IsDigit(ch);
9899
(void)IsSpace(ch);
99100
(void)IsSwitchChar(ch);
100-
(void)itostr(i32);
101101
(void)memusage::DynamicUsage(ch);
102102
(void)memusage::DynamicUsage(i16);
103103
(void)memusage::DynamicUsage(i32);

src/test/fuzz/locale.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5-
#include <test/fuzz/fuzz.h>
65
#include <test/fuzz/FuzzedDataProvider.h>
6+
#include <test/fuzz/fuzz.h>
77
#include <tinyformat.h>
88
#include <util/strencodings.h>
9+
#include <util/string.h>
910

1011
#include <cassert>
1112
#include <clocale>
@@ -54,9 +55,8 @@ void test_one_input(const std::vector<uint8_t>& buffer)
5455
const int atoi_without_locale = atoi(random_string);
5556
const int64_t atoi64c_without_locale = atoi64(random_string.c_str());
5657
const int64_t random_int64 = fuzzed_data_provider.ConsumeIntegral<int64_t>();
57-
const std::string i64tostr_without_locale = i64tostr(random_int64);
58+
const std::string tostring_without_locale = ToString(random_int64);
5859
const int32_t random_int32 = fuzzed_data_provider.ConsumeIntegral<int32_t>();
59-
const std::string itostr_without_locale = itostr(random_int32);
6060
const std::string strprintf_int_without_locale = strprintf("%d", random_int64);
6161
const double random_double = fuzzed_data_provider.ConsumeFloatingPoint<double>();
6262
const std::string strprintf_double_without_locale = strprintf("%f", random_double);
@@ -82,10 +82,8 @@ void test_one_input(const std::vector<uint8_t>& buffer)
8282
assert(atoi64c_without_locale == atoi64c_with_locale);
8383
const int atoi_with_locale = atoi(random_string);
8484
assert(atoi_without_locale == atoi_with_locale);
85-
const std::string i64tostr_with_locale = i64tostr(random_int64);
86-
assert(i64tostr_without_locale == i64tostr_with_locale);
87-
const std::string itostr_with_locale = itostr(random_int32);
88-
assert(itostr_without_locale == itostr_with_locale);
85+
const std::string tostring_with_locale = ToString(random_int64);
86+
assert(tostring_without_locale == tostring_with_locale);
8987
const std::string strprintf_int_with_locale = strprintf("%d", random_int64);
9088
assert(strprintf_int_without_locale == strprintf_int_with_locale);
9189
const std::string strprintf_double_with_locale = strprintf("%f", random_double);

src/util/strencodings.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -407,16 +407,6 @@ std::string FormatParagraph(const std::string& in, size_t width, size_t indent)
407407
return out.str();
408408
}
409409

410-
std::string i64tostr(int64_t n)
411-
{
412-
return strprintf("%d", n);
413-
}
414-
415-
std::string itostr(int n)
416-
{
417-
return strprintf("%d", n);
418-
}
419-
420410
int64_t atoi64(const char* psz)
421411
{
422412
#ifdef _MSC_VER

src/util/strencodings.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ std::string DecodeBase32(const std::string& str, bool* pf_invalid = nullptr);
5454
std::string EncodeBase32(const unsigned char* pch, size_t len);
5555
std::string EncodeBase32(const std::string& str);
5656

57-
void SplitHostPort(std::string in, int &portOut, std::string &hostOut);
58-
std::string i64tostr(int64_t n);
59-
std::string itostr(int n);
57+
void SplitHostPort(std::string in, int& portOut, std::string& hostOut);
6058
int64_t atoi64(const char* psz);
6159
int64_t atoi64(const std::string& str);
6260
int atoi(const std::string& str);

src/wallet/wallet.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <ui_interface.h>
1717
#include <util/message.h>
1818
#include <util/strencodings.h>
19+
#include <util/string.h>
1920
#include <util/system.h>
2021
#include <validationinterface.h>
2122
#include <wallet/coinselection.h>
@@ -215,7 +216,7 @@ static inline void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue)
215216
{
216217
if (nOrderPos == -1)
217218
return;
218-
mapValue["n"] = i64tostr(nOrderPos);
219+
mapValue["n"] = ToString(nOrderPos);
219220
}
220221

221222
struct COutputEntry

0 commit comments

Comments
 (0)