aboutsummaryrefslogtreecommitdiff
path: root/src/uint256.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/uint256.h')
-rw-r--r--src/uint256.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/uint256.h b/src/uint256.h
index 79404f1b16..b5a4950eaa 100644
--- a/src/uint256.h
+++ b/src/uint256.h
@@ -14,7 +14,12 @@
typedef long long int64;
typedef unsigned long long uint64;
+extern const signed char p_util_hexdigit[256]; // defined in util.cpp
+inline signed char HexDigit(char c)
+{
+ return p_util_hexdigit[(unsigned char)c];
+}
inline int Testuint256AdHoc(std::vector<std::string> vArg);
@@ -305,8 +310,7 @@ public:
void SetHex(const char* psz)
{
- for (int i = 0; i < WIDTH; i++)
- pn[i] = 0;
+ memset(pn,0,sizeof(pn));
// skip leading spaces
while (isspace(*psz))
@@ -317,19 +321,18 @@ public:
psz += 2;
// hex string to uint
- static const unsigned char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 };
const char* pbegin = psz;
- while (phexdigit[(unsigned char)*psz] || *psz == '0')
+ while (::HexDigit(*psz) != -1)
psz++;
psz--;
unsigned char* p1 = (unsigned char*)pn;
unsigned char* pend = p1 + WIDTH * 4;
while (psz >= pbegin && p1 < pend)
{
- *p1 = phexdigit[(unsigned char)*psz--];
+ *p1 = ::HexDigit(*psz--);
if (psz >= pbegin)
{
- *p1 |= (phexdigit[(unsigned char)*psz--] << 4);
+ *p1 |= ((unsigned char)::HexDigit(*psz--) << 4);
p1++;
}
}