summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--absl/container/btree_map.h7
-rw-r--r--absl/strings/internal/cord_internal.h30
-rw-r--r--absl/strings/internal/cord_rep_flat.h11
-rw-r--r--absl/strings/internal/cord_rep_ring.h11
4 files changed, 33 insertions, 26 deletions
diff --git a/absl/container/btree_map.h b/absl/container/btree_map.h
index abc09b0a..ea49d446 100644
--- a/absl/container/btree_map.h
+++ b/absl/container/btree_map.h
@@ -384,9 +384,8 @@ class btree_map
// btree_map::equal_range()
//
- // Returns a closed range [first, last], defined by a `std::pair` of two
- // iterators, containing all elements with the passed key in the
- // `btree_map`.
+ // Returns a half-open range [first, last), defined by a `std::pair` of two
+ // iterators, containing all elements with the passed key in the `btree_map`.
using Base::equal_range;
// btree_map::find()
@@ -709,7 +708,7 @@ class btree_multimap
// btree_multimap::equal_range()
//
- // Returns a closed range [first, last], defined by a `std::pair` of two
+ // Returns a half-open range [first, last), defined by a `std::pair` of two
// iterators, containing all elements with the passed key in the
// `btree_multimap`.
using Base::equal_range;
diff --git a/absl/strings/internal/cord_internal.h b/absl/strings/internal/cord_internal.h
index 7a1ef6b1..96502433 100644
--- a/absl/strings/internal/cord_internal.h
+++ b/absl/strings/internal/cord_internal.h
@@ -456,8 +456,14 @@ class InlineData {
struct AsTree {
explicit constexpr AsTree(absl::cord_internal::CordRep* tree)
: rep(tree), cordz_info(kNullCordzInfo) {}
- absl::cord_internal::CordRep* rep;
- alignas(sizeof(cordz_info_t)) cordz_info_t cordz_info;
+ // This union uses up extra space so that whether rep is 32 or 64 bits,
+ // cordz_info will still start at the eighth byte, and the last
+ // byte of cordz_info will still be the last byte of InlineData.
+ union {
+ absl::cord_internal::CordRep* rep;
+ cordz_info_t unused_aligner;
+ };
+ cordz_info_t cordz_info;
};
char& tag() { return reinterpret_cast<char*>(this)[kMaxInline]; }
@@ -505,26 +511,6 @@ inline const CordRepExternal* CordRep::external() const {
return static_cast<const CordRepExternal*>(this);
}
-inline CordRepFlat* CordRep::flat() {
- assert(tag >= FLAT && tag <= MAX_FLAT_TAG);
- return reinterpret_cast<CordRepFlat*>(this);
-}
-
-inline const CordRepFlat* CordRep::flat() const {
- assert(tag >= FLAT && tag <= MAX_FLAT_TAG);
- return reinterpret_cast<const CordRepFlat*>(this);
-}
-
-inline CordRepRing* CordRep::ring() {
- assert(tag == RING);
- return reinterpret_cast<CordRepRing*>(this);
-}
-
-inline const CordRepRing* CordRep::ring() const {
- assert(tag == RING);
- return reinterpret_cast<const CordRepRing*>(this);
-}
-
inline CordRep* CordRep::Ref(CordRep* rep) {
assert(rep != nullptr);
rep->refcount.Increment();
diff --git a/absl/strings/internal/cord_rep_flat.h b/absl/strings/internal/cord_rep_flat.h
index 5f7d55ce..55418153 100644
--- a/absl/strings/internal/cord_rep_flat.h
+++ b/absl/strings/internal/cord_rep_flat.h
@@ -127,6 +127,17 @@ struct CordRepFlat : public CordRep {
size_t AllocatedSize() const { return TagToAllocatedSize(tag); }
};
+// Now that CordRepFlat is defined, we can define CordRep's helper casts:
+inline CordRepFlat* CordRep::flat() {
+ assert(tag >= FLAT && tag <= MAX_FLAT_TAG);
+ return reinterpret_cast<CordRepFlat*>(this);
+}
+
+inline const CordRepFlat* CordRep::flat() const {
+ assert(tag >= FLAT && tag <= MAX_FLAT_TAG);
+ return reinterpret_cast<const CordRepFlat*>(this);
+}
+
} // namespace cord_internal
ABSL_NAMESPACE_END
} // namespace absl
diff --git a/absl/strings/internal/cord_rep_ring.h b/absl/strings/internal/cord_rep_ring.h
index e6f6b59c..55cba8b4 100644
--- a/absl/strings/internal/cord_rep_ring.h
+++ b/absl/strings/internal/cord_rep_ring.h
@@ -563,6 +563,17 @@ inline CordRepRing::Position CordRepRing::FindTail(index_type head,
return (offset == length) ? Position{tail_, 0} : FindTailSlow(head, offset);
}
+// Now that CordRepRing is defined, we can define CordRep's helper casts:
+inline CordRepRing* CordRep::ring() {
+ assert(tag == RING);
+ return static_cast<CordRepRing*>(this);
+}
+
+inline const CordRepRing* CordRep::ring() const {
+ assert(tag == RING);
+ return static_cast<const CordRepRing*>(this);
+}
+
std::ostream& operator<<(std::ostream& s, const CordRepRing& rep);
#ifdef __clang__