summaryrefslogtreecommitdiff
path: root/src/mongo/util/uuid.cpp
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2020-09-11 15:53:00 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-12 19:27:01 +0000
commite0ee9c97a8c572a8e513ad8c097a5c867d34222b (patch)
treec3601b3a20c7532f70003a5a4fa99687a9d311e9 /src/mongo/util/uuid.cpp
parent86bc3de7ead3c1229530d05b192ba8ee43d5132c (diff)
downloadmongo-e0ee9c97a8c572a8e513ad8c097a5c867d34222b.tar.gz
SERVER-50894 convert std::regex to pcrecpp::RE
Diffstat (limited to 'src/mongo/util/uuid.cpp')
-rw-r--r--src/mongo/util/uuid.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/mongo/util/uuid.cpp b/src/mongo/util/uuid.cpp
index 63ca7bc1e2d..cc4fd3b907e 100644
--- a/src/mongo/util/uuid.cpp
+++ b/src/mongo/util/uuid.cpp
@@ -29,14 +29,15 @@
#include "mongo/platform/basic.h"
-#include <regex>
-
#include "mongo/util/uuid.h"
+#include <pcrecpp.h>
+
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/platform/mutex.h"
#include "mongo/platform/random.h"
#include "mongo/util/hex.h"
+#include "mongo/util/static_immortal.h"
namespace mongo {
@@ -45,10 +46,6 @@ namespace {
Mutex uuidGenMutex;
SecureRandom uuidGen;
-// Regex to match valid version 4 UUIDs with variant bits set
-std::regex uuidRegex("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}",
- std::regex::optimize);
-
} // namespace
StatusWith<UUID> UUID::parse(BSONElement from) {
@@ -89,7 +86,14 @@ UUID UUID::parse(const BSONObj& obj) {
}
bool UUID::isUUIDString(const std::string& s) {
- return std::regex_match(s, uuidRegex);
+ // Regex to match valid version 4 UUIDs with variant bits set
+ static StaticImmortal<pcrecpp::RE> uuidRegex(
+ "[[:xdigit:]]{8}-"
+ "[[:xdigit:]]{4}-"
+ "[[:xdigit:]]{4}-"
+ "[[:xdigit:]]{4}-"
+ "[[:xdigit:]]{12}");
+ return uuidRegex->FullMatch(s);
}
bool UUID::isRFC4122v4() const {