diff options
| author | Wladimir J. van der Laan <[email protected]> | 2019-01-10 01:46:32 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2019-01-10 02:51:14 +0100 |
| commit | 332b3dd7c156daa08df347dc3359f0ee99ce4baa (patch) | |
| tree | bbd9ee1fdcad37089529f7728774150562e2c0e4 /src/util | |
| parent | util: remove unused [U](BEGIN|END) macros (diff) | |
| download | discoin-332b3dd7c156daa08df347dc3359f0ee99ce4baa.tar.xz discoin-332b3dd7c156daa08df347dc3359f0ee99ce4baa.zip | |
util: Make ToLower and ToUpper take a char
Unfortunately, `std::string` elements are (bare) chars. As these
are the most likely type to be passed to these functions, make them use
char instead of unsigned char. This avoids some casts.
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/strencodings.cpp | 2 | ||||
| -rw-r--r-- | src/util/strencodings.h | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/util/strencodings.cpp b/src/util/strencodings.cpp index 46146be66..fedeeac39 100644 --- a/src/util/strencodings.cpp +++ b/src/util/strencodings.cpp @@ -589,7 +589,7 @@ bool ParseHDKeypath(const std::string& keypath_str, std::vector<uint32_t>& keypa void Downcase(std::string& str) { - std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c){return ToLower(c);}); + std::transform(str.begin(), str.end(), str.begin(), [](char c){return ToLower(c);}); } std::string Capitalize(std::string str) diff --git a/src/util/strencodings.h b/src/util/strencodings.h index e219e7df3..e392055f2 100644 --- a/src/util/strencodings.h +++ b/src/util/strencodings.h @@ -208,7 +208,7 @@ NODISCARD bool ParseHDKeypath(const std::string& keypath_str, std::vector<uint32 * @return the lowercase equivalent of c; or the argument * if no conversion is possible. */ -constexpr unsigned char ToLower(unsigned char c) +constexpr char ToLower(char c) { return (c >= 'A' && c <= 'Z' ? (c - 'A') + 'a' : c); } @@ -229,7 +229,7 @@ void Downcase(std::string& str); * @return the uppercase equivalent of c; or the argument * if no conversion is possible. */ -constexpr unsigned char ToUpper(unsigned char c) +constexpr char ToUpper(char c) { return (c >= 'a' && c <= 'z' ? (c - 'a') + 'A' : c); } |