summaryrefslogtreecommitdiff
path: root/src/mongo/platform
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2020-09-09 21:32:04 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-15 00:42:05 +0000
commit58828b0ce9556ee9cb38c484d1226663a0dcd993 (patch)
treedfea448799d9bd4328114199a9767dd18d045be3 /src/mongo/platform
parent22a77301a5b63b9bb7ef6dd73eabb4865c63a921 (diff)
downloadmongo-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.cpp13
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));
}