@@ -24,13 +24,12 @@ namespace spanner {
2424GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
2525namespace {
2626
27- constexpr int kMaxUuidNumberOfHexDigits = 32 ;
28-
2927// Helper function to parse a single hexadecimal block of a UUID.
3028// A hexadecimal block is a 16-digit hexadecimal number, which is represented
3129// as 8 bytes.
3230StatusOr<std::uint64_t > ParseHexBlock (absl::string_view& str,
3331 absl::string_view original_str) {
32+ constexpr int kMaxUuidNumberOfHexDigits = 32 ;
3433 constexpr int kMaxUuidBlockLength = 16 ;
3534 static auto const * char_to_hex = new absl::flat_hash_map<char , std::uint8_t >(
3635 {{' 0' , 0x00 }, {' 1' , 0x01 }, {' 2' , 0x02 }, {' 3' , 0x03 }, {' 4' , 0x04 },
@@ -73,14 +72,6 @@ Uuid::Uuid(absl::uint128 value) : uuid_(value) {}
7372Uuid::Uuid (std::uint64_t high_bits, std::uint64_t low_bits)
7473 : Uuid(absl::MakeUint128(high_bits, low_bits)) {}
7574
76- bool operator ==(Uuid const & lhs, Uuid const & rhs) {
77- return lhs.uuid_ == rhs.uuid_ ;
78- }
79-
80- bool operator <(Uuid const & lhs, Uuid const & rhs) {
81- return lhs.uuid_ < rhs.uuid_ ;
82- }
83-
8475Uuid::operator std::string () const {
8576 constexpr int kUuidStringLen = 36 ;
8677 constexpr int kChunkLength [] = {8 , 4 , 4 , 4 , 12 };
@@ -95,7 +86,7 @@ Uuid::operator std::string() const {
9586
9687 std::string output;
9788 output.resize (kUuidStringLen );
98- char * target = &(( output)[output. size () - kUuidStringLen ] );
89+ char * target = const_cast < char *>( output. data () );
9990 char * const last = &((output)[output.size ()]);
10091 auto bits = Uint128High64 (uuid_);
10192 int start = 16 ;
@@ -131,7 +122,7 @@ StatusOr<Uuid> MakeUuid(absl::string_view str) {
131122 }
132123
133124 // Check for leading hyphen after stripping any surrounding braces.
134- if (str[ 0 ] == ' - ' ) {
125+ if (absl::StartsWith ( str, " - " ) ) {
135126 return internal::InvalidArgumentError (
136127 absl::StrFormat (" UUID cannot begin with '-': %s" , original_str),
137128 GCP_ERROR_INFO ());
@@ -144,8 +135,7 @@ StatusOr<Uuid> MakeUuid(absl::string_view str) {
144135
145136 if (!str.empty ()) {
146137 return internal::InvalidArgumentError (
147- absl::StrFormat (" Extra characters (%d) found after parsing UUID: %s" ,
148- str.size (), original_str),
138+ absl::StrFormat (" Extra characters found after parsing UUID: %s" , str),
149139 GCP_ERROR_INFO ());
150140 }
151141
0 commit comments