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 /base32.cpp | |
parent | 62f92dd592a1685e7fee99165ec9350aee368c37 (diff) | |
download | cryptopp-git-0dc97f1d3a801c33b16e746c1515f0723cf23790.tar.gz |
Unroll decoder initialization (Issue 376)
Diffstat (limited to 'base32.cpp')
-rw-r--r-- | base32.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
@@ -26,16 +26,30 @@ void Base32Decoder::IsolatedInitialize(const NameValuePairs ¶meters) MakeParameters(Name::DecodingLookupArray(), GetDefaultDecodingLookupArray(), false)(Name::Log2Base(), 5, 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,
+ -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, -1,
+ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, 11, 12, -1,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, -1, -1, -1, -1, -1,
+ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, 11, 12, -1,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, -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 *Base32Decoder::GetDefaultDecodingLookupArray()
{
- static volatile bool s_initialized = false;
- static int s_array[256];
-
- if (!s_initialized)
- {
- InitializeDecodingLookupArray(s_array, s_vecUpper, 32, true);
- s_initialized = true;
- }
return s_array;
}
|