diff options
author | Martijn Vels <mvels@google.com> | 2022-09-29 18:14:53 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-09-29 18:15:59 -0700 |
commit | 92bc0b6b68cd138aefeb94d566499f5bf14f859f (patch) | |
tree | a2558321254062576ad4fc30c792ae88b7542ba6 /absl/strings/cord.h | |
parent | b39aa365e14984035bbbe60f52ec40a66419f18e (diff) | |
download | abseil-92bc0b6b68cd138aefeb94d566499f5bf14f859f.tar.gz abseil-92bc0b6b68cd138aefeb94d566499f5bf14f859f.tar.bz2 abseil-92bc0b6b68cd138aefeb94d566499f5bf14f859f.zip |
Cleanup: Move BitwiseCompare() to InlineData, and make it layout independent.
This removes layout specific details from InlineData from cord.h, making future platform specific internal layout changes easier to land.
PiperOrigin-RevId: 477869206
Change-Id: I1d417af47d7f04e34a98ba7b93ae591ece8f9151
Diffstat (limited to 'absl/strings/cord.h')
-rw-r--r-- | absl/strings/cord.h | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/absl/strings/cord.h b/absl/strings/cord.h index e8267ab1..d7e5a45e 100644 --- a/absl/strings/cord.h +++ b/absl/strings/cord.h @@ -876,20 +876,6 @@ class Cord { bool IsSame(const InlineRep& other) const { return memcmp(&data_, &other.data_, sizeof(data_)) == 0; } - int BitwiseCompare(const InlineRep& other) const { - uint64_t x, y; - // Use memcpy to avoid aliasing issues. - memcpy(&x, &data_, sizeof(x)); - memcpy(&y, &other.data_, sizeof(y)); - if (x == y) { - memcpy(&x, reinterpret_cast<const char*>(&data_) + 8, sizeof(x)); - memcpy(&y, reinterpret_cast<const char*>(&other.data_) + 8, sizeof(y)); - if (x == y) return 0; - } - return absl::big_endian::FromHost64(x) < absl::big_endian::FromHost64(y) - ? -1 - : 1; - } void CopyTo(std::string* dst) const { // memcpy is much faster when operating on a known size. On most supported // platforms, the small string optimization is large enough that resizing @@ -1387,7 +1373,7 @@ extern template void Cord::Prepend(std::string&& src); inline int Cord::Compare(const Cord& rhs) const { if (!contents_.is_tree() && !rhs.contents_.is_tree()) { - return contents_.BitwiseCompare(rhs.contents_); + return contents_.data_.Compare(rhs.contents_.data_); } return CompareImpl(rhs); |