summaryrefslogtreecommitdiff
path: root/integer.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-01-02 04:17:22 -0500
committerJeffrey Walton <noloader@gmail.com>2018-01-02 04:17:22 -0500
commitfb0ecfde6244babd00b9a44452d634fea45cd5d1 (patch)
tree16b0aedcdf2bf3bd14af64e5be3a2633b510be02 /integer.cpp
parent1a7f19cdde7c84c88f96c5a5125447a9f4df0025 (diff)
downloadcryptopp-git-fb0ecfde6244babd00b9a44452d634fea45cd5d1.tar.gz
Clear clang-tidy warnings
This commit also tweaks the way Integer parses byte arrays. The modified routines are slightly faster. On a Core-i5 6400 the self tests are 0.1 to 0.2 seconds faster
Diffstat (limited to 'integer.cpp')
-rw-r--r--integer.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/integer.cpp b/integer.cpp
index 691746d1..16112575 100644
--- a/integer.cpp
+++ b/integer.cpp
@@ -2994,17 +2994,18 @@ Integer::Integer(BufferedTransformation &encodedInteger, size_t byteCount, Signe
{
CRYPTOPP_ASSERT(o == BIG_ENDIAN_ORDER || o == LITTLE_ENDIAN_ORDER);
- if (o == LITTLE_ENDIAN_ORDER)
+ if (o != LITTLE_ENDIAN_ORDER)
+ {
+ Decode(encodedInteger, byteCount, s);
+ }
+ else
{
SecByteBlock block(byteCount);
encodedInteger.Get(block, block.size());
std::reverse(block.begin(), block.begin()+block.size());
Decode(block.begin(), block.size(), s);
- return;
}
-
- Decode(encodedInteger, byteCount, s);
}
Integer::Integer(const byte *encodedInteger, size_t byteCount, Signedness s, ByteOrder o)
@@ -3012,7 +3013,11 @@ Integer::Integer(const byte *encodedInteger, size_t byteCount, Signedness s, Byt
CRYPTOPP_ASSERT(encodedInteger && byteCount); // NULL buffer
CRYPTOPP_ASSERT(o == BIG_ENDIAN_ORDER || o == LITTLE_ENDIAN_ORDER);
- if (o == LITTLE_ENDIAN_ORDER)
+ if (o != LITTLE_ENDIAN_ORDER)
+ {
+ Decode(encodedInteger, byteCount, s);
+ }
+ else
{
SecByteBlock block(byteCount);
#if (_MSC_FULL_VER >= 140050727)
@@ -3024,13 +3029,12 @@ Integer::Integer(const byte *encodedInteger, size_t byteCount, Signedness s, Byt
Decode(block.begin(), block.size(), s);
return;
}
-
- Decode(encodedInteger, byteCount, s);
}
Integer::Integer(BufferedTransformation &bt)
{
- BERDecode(bt);
+ // Make explicit call to avoid virtual-dispatch findings in ctor
+ Integer::BERDecode(bt);
}
Integer::Integer(RandomNumberGenerator &rng, size_t bitcount)