diff options
author | Brad King <brad.king@kitware.com> | 2019-02-20 14:02:06 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-02-20 14:02:51 (GMT) |
commit | b38023f958325fedd99d5480149f4958e721fdd5 (patch) | |
tree | 41738ed459584ee3eebd3b9adfd350d57d7baff7 | |
parent | bb6d46d7e4f65bad099b919ffb1e34c0571ca727 (diff) | |
parent | 8a95808f8fb0766197ff904bc0c47ad9afa54098 (diff) | |
download | CMake-b38023f958325fedd99d5480149f4958e721fdd5.zip CMake-b38023f958325fedd99d5480149f4958e721fdd5.tar.gz CMake-b38023f958325fedd99d5480149f4958e721fdd5.tar.bz2 |
Merge topic 'optimize-cmuuid-ctor'
8a95808f8f cmUuid: Hide UUID group info in implementation
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2976
-rw-r--r-- | Source/cmUuid.cxx | 18 | ||||
-rw-r--r-- | Source/cmUuid.h | 4 |
2 files changed, 6 insertions, 16 deletions
diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx index 201e1cc..51ecbd1 100644 --- a/Source/cmUuid.cxx +++ b/Source/cmUuid.cxx @@ -4,16 +4,10 @@ #include "cmCryptoHash.h" +#include <array> #include <string.h> -cmUuid::cmUuid() -{ - Groups.push_back(4); - Groups.push_back(2); - Groups.push_back(2); - Groups.push_back(2); - Groups.push_back(6); -} +static const std::array<int, 5> kUuidGroups = { { 4, 2, 2, 2, 6 } }; std::string cmUuid::FromMd5(std::vector<unsigned char> const& uuidNamespace, std::string const& name) const @@ -83,11 +77,11 @@ bool cmUuid::StringToBinary(std::string const& input, return false; } size_t index = 0; - for (size_t i = 0; i < this->Groups.size(); ++i) { + for (size_t i = 0; i < kUuidGroups.size(); ++i) { if (i != 0 && input[index++] != '-') { return false; } - size_t digits = this->Groups[i] * 2; + size_t digits = kUuidGroups[i] * 2; if (!StringToBinaryImpl(input.substr(index, digits), output)) { return false; } @@ -103,12 +97,12 @@ std::string cmUuid::BinaryToString(const unsigned char* input) const std::string output; size_t inputIndex = 0; - for (size_t i = 0; i < this->Groups.size(); ++i) { + for (size_t i = 0; i < kUuidGroups.size(); ++i) { if (i != 0) { output += '-'; } - size_t bytes = this->Groups[i]; + size_t bytes = kUuidGroups[i]; for (size_t j = 0; j < bytes; ++j) { unsigned char byte = input[inputIndex++]; output += this->ByteToHex(byte); diff --git a/Source/cmUuid.h b/Source/cmUuid.h index 158ce6e..7de20dd 100644 --- a/Source/cmUuid.h +++ b/Source/cmUuid.h @@ -15,8 +15,6 @@ class cmUuid { public: - cmUuid(); - std::string FromMd5(std::vector<unsigned char> const& uuidNamespace, std::string const& name) const; @@ -42,8 +40,6 @@ private: std::string BinaryToString(const unsigned char* input) const; bool IntFromHexDigit(char input, char& output) const; - - std::vector<int> Groups; }; #endif |