diff options
author | Jeffrey Walton <noloader@gmail.com> | 2017-03-01 02:19:12 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2017-03-01 02:19:12 -0500 |
commit | 0dc97f1d3a801c33b16e746c1515f0723cf23790 (patch) | |
tree | f7414e418cabe48621759b6270ee75de60248fac /hex.cpp | |
parent | 62f92dd592a1685e7fee99165ec9350aee368c37 (diff) | |
download | cryptopp-git-0dc97f1d3a801c33b16e746c1515f0723cf23790.tar.gz |
Unroll decoder initialization (Issue 376)
Diffstat (limited to 'hex.cpp')
-rw-r--r-- | hex.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
@@ -29,16 +29,30 @@ void HexDecoder::IsolatedInitialize(const NameValuePairs ¶meters) MakeParameters(Name::DecodingLookupArray(), GetDefaultDecodingLookupArray(), false)(Name::Log2Base(), 4, true)));
}
+ANONYMOUS_NAMESPACE_BEGIN
+static const int s_array[256] = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
+ -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
+};
+NAMESPACE_END
+
+// Unrolled initialization, http://github.com/weidai11/cryptopp/issues/376
const int *HexDecoder::GetDefaultDecodingLookupArray()
{
- static volatile bool s_initialized = false;
- static int s_array[256];
-
- if (!s_initialized)
- {
- InitializeDecodingLookupArray(s_array, s_vecUpper, 16, true);
- s_initialized = true;
- }
return s_array;
}
|