diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2020-09-09 21:32:04 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-15 00:42:05 +0000 |
commit | 58828b0ce9556ee9cb38c484d1226663a0dcd993 (patch) | |
tree | dfea448799d9bd4328114199a9767dd18d045be3 /src/mongo/platform | |
parent | 22a77301a5b63b9bb7ef6dd73eabb4865c63a921 (diff) | |
download | mongo-58828b0ce9556ee9cb38c484d1226663a0dcd993.tar.gz |
SERVER-43909 clarify and repair util/hex.h API
- hexblob namespace
- Throwy hexblob::decode (nee fromHex)
- StringData overloads of hex codec ops
- add unsignedHex<T> and zeroPaddedHex<T>
Diffstat (limited to 'src/mongo/platform')
-rw-r--r-- | src/mongo/platform/decimal128_bson_test.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/mongo/platform/decimal128_bson_test.cpp b/src/mongo/platform/decimal128_bson_test.cpp index 1f34da163d6..f0d0ffd506a 100644 --- a/src/mongo/platform/decimal128_bson_test.cpp +++ b/src/mongo/platform/decimal128_bson_test.cpp @@ -31,6 +31,7 @@ #include "mongo/platform/basic.h" +#include <algorithm> #include <array> #include <cmath> #include <memory> @@ -54,15 +55,9 @@ const std::string testData = initTestData(); using namespace mongo; BSONObj convertHexStringToBsonObj(StringData hexString) { - const char* p = hexString.rawData(); - size_t bufferSize = hexString.size() / 2; - auto buffer = SharedBuffer::allocate(bufferSize); - - for (unsigned int i = 0; i < bufferSize; i++) { - buffer.get()[i] = uassertStatusOK(fromHex(p)); - p += 2; - } - + std::string data = hexblob::decode(hexString); + auto buffer = SharedBuffer::allocate(data.size()); + std::copy(data.begin(), data.end(), buffer.get()); return BSONObj(std::move(buffer)); } |