From f171ec0c7d084b6bb163d1466edd814cf4dcbc93 Mon Sep 17 00:00:00 2001 From: Olivier Langlois Date: Thu, 10 Oct 2013 12:35:51 -0400 Subject: Make util phexdigit array reusable class template base_uint had its own private lookup table. This is saving 256 bytes per instantiation. The result is not spectacular as bitcoin-qt has only shrinked of about 1Kb but it is still valid improvement. Also, I have replaced a for loop with a memset() call. Made CBigNum::SetHex() use the new HexDigit() function. Signed-off-by: Olivier Langlois --- src/bignum.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/bignum.h') diff --git a/src/bignum.h b/src/bignum.h index 0881807d70..98655cc0e9 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -347,13 +347,13 @@ public: psz++; // hex string to bignum - static const signed 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 }; *this = 0; - while (isxdigit(*psz)) + int n; + while ((n = HexDigit(*psz)) != -1) { *this <<= 4; - int n = phexdigit[(unsigned char)*psz++]; *this += n; + ++psz; } if (fNegative) *this = 0 - *this; -- cgit v1.2.3