Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/merkleblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ uint256 CPartialMerkleTree::CalcHash(int height, unsigned int pos, const std::ve
else
right = left;
// combine subhashes
return Hash(BEGIN(left), END(left), BEGIN(right), END(right));
return Hash(left.begin(), left.end(), right.begin(), right.end());
}
}

Expand Down Expand Up @@ -109,7 +109,7 @@ uint256 CPartialMerkleTree::TraverseAndExtract(int height, unsigned int pos, uns
right = left;
}
// and combine them before returning
return Hash(BEGIN(left), END(left), BEGIN(right), END(right));
return Hash(left.begin(), left.end(), right.begin(), right.end());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/merkle_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ static uint256 ComputeMerkleRootFromBranch(const uint256& leaf, const std::vecto
uint256 hash = leaf;
for (std::vector<uint256>::const_iterator it = vMerkleBranch.begin(); it != vMerkleBranch.end(); ++it) {
if (nIndex & 1) {
hash = Hash(BEGIN(*it), END(*it), BEGIN(hash), END(hash));
hash = Hash(it->begin(), it->end(), hash.begin(), hash.end());
} else {
hash = Hash(BEGIN(hash), END(hash), BEGIN(*it), END(*it));
hash = Hash(hash.begin(), hash.end(), it->begin(), it->end());
}
nIndex >>= 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/util_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ BOOST_AUTO_TEST_CASE(test_ToLower)
BOOST_CHECK_EQUAL(ToLower('Z'), 'z');
BOOST_CHECK_EQUAL(ToLower('['), '[');
BOOST_CHECK_EQUAL(ToLower(0), 0);
BOOST_CHECK_EQUAL(ToLower(255), 255);
BOOST_CHECK_EQUAL(ToLower('\xff'), '\xff');

std::string testVector;
Downcase(testVector);
Expand All @@ -1246,7 +1246,7 @@ BOOST_AUTO_TEST_CASE(test_ToUpper)
BOOST_CHECK_EQUAL(ToUpper('z'), 'Z');
BOOST_CHECK_EQUAL(ToUpper('{'), '{');
BOOST_CHECK_EQUAL(ToUpper(0), 0);
BOOST_CHECK_EQUAL(ToUpper(255), 255);
BOOST_CHECK_EQUAL(ToUpper('\xff'), '\xff');
}

BOOST_AUTO_TEST_CASE(test_Capitalize)
Expand Down
2 changes: 1 addition & 1 deletion src/uint256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void base_blob<BITS>::SetHex(const char* psz)
psz++;

// skip 0x
if (psz[0] == '0' && ToLower((unsigned char)psz[1]) == 'x')
if (psz[0] == '0' && ToLower(psz[1]) == 'x')
psz += 2;

// hex string to uint
Expand Down
2 changes: 1 addition & 1 deletion src/util/strencodings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realizing that it's passing a silly identity function:

std::transform(str.begin(), str.end(), str.begin(), ToLower);

Anyhow, not going to file a PR for just that, I guess the compiler optimizes this away, maybe someone touching this code in the future can take it into account.

}

std::string Capitalize(std::string str)
Expand Down
8 changes: 2 additions & 6 deletions src/util/strencodings.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
#include <string>
#include <vector>

#define BEGIN(a) ((char*)&(a))
#define END(a) ((char*)&((&(a))[1]))
#define UBEGIN(a) ((unsigned char*)&(a))
#define UEND(a) ((unsigned char*)&((&(a))[1]))
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))

/** Used by SanitizeString() */
Expand Down Expand Up @@ -212,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);
}
Expand All @@ -233,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);
}
Expand Down