summaryrefslogtreecommitdiff
path: root/absl/strings/internal/cord_internal.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2021-01-13 08:30:42 -0800
committerGravatar Andy Getzendanner <durandal@google.com>2021-01-13 20:11:55 +0000
commit64461421222f8be8663c50e8e82c91c3f95a0d3c (patch)
tree4dfdeaf9700fef7aceb137d122702f529aa51556 /absl/strings/internal/cord_internal.h
parent322ae2420d27fc96d0a8ab1167d7de33671048df (diff)
Export of internal Abseil changes
-- a0491c8d790972cd80e2d720fe1fdf5f711a6f1a by Greg Falcon <gfalcon@google.com>: Stop directly accessing CordRepFlat data via CordRep::data. The old pattern of access breaks the `CordRep` type abstraction; since `CordRep::data` is not in general guaranteed to contain the chunk's data, we shouldn't access it that way. This incidentally adds an assertion check (via the flat() accessor) that the CordRep is indeed flat on each such access, but a manual inspection of the code, as well as the fact that this code currently works, suggest that this is always true.) PiperOrigin-RevId: 351592344 -- f40c3b43ca5b1d7e23cd45f1ffac1783105ac1a3 by Abseil Team <absl-team@google.com>: Revert 18abb2902b9f06c63a968b24d3dda785ebf99a22 PiperOrigin-RevId: 351523518 -- 18abb2902b9f06c63a968b24d3dda785ebf99a22 by Abseil Team <absl-team@google.com>: Internal change PiperOrigin-RevId: 351512412 -- 9b881602d45e95e06089792c7627cd56528a255a by Abseil Team <absl-team@google.com>: Keep time's global state in a cacheline-aligned structure. Keeping the global state as separate global variables results in two issues: 1) False sharing with adjacent global data (e.g., cycle clock source), since the global fields are updated every O(10usec). 2) The hot global fields (e.g., seq and samples) can reside on different cache lines. To fix this, simply wrap the global data in a ABSL_CACHE_ALIGNED structure. This is similar to what we do for MutexGlobals. PiperOrigin-RevId: 351389466 GitOrigin-RevId: a0491c8d790972cd80e2d720fe1fdf5f711a6f1a Change-Id: Ie0fa80112043381cd37c84e2ab2b7334839f54b5
Diffstat (limited to 'absl/strings/internal/cord_internal.h')
-rw-r--r--absl/strings/internal/cord_internal.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/absl/strings/internal/cord_internal.h b/absl/strings/internal/cord_internal.h
index 57e7046a..b586ea37 100644
--- a/absl/strings/internal/cord_internal.h
+++ b/absl/strings/internal/cord_internal.h
@@ -166,7 +166,7 @@ enum CordRepKind {
struct CordRep {
CordRep() = default;
constexpr CordRep(Refcount::Immortal immortal, size_t l)
- : length(l), refcount(immortal), tag(EXTERNAL), data{} {}
+ : length(l), refcount(immortal), tag(EXTERNAL), storage{} {}
// The following three fields have to be less than 32 bytes since
// that is the smallest supported flat node size.
@@ -175,7 +175,7 @@ struct CordRep {
// If tag < FLAT, it represents CordRepKind and indicates the type of node.
// Otherwise, the node type is CordRepFlat and the tag is the encoded size.
uint8_t tag;
- char data[1]; // Starting point for flat array: MUST BE LAST FIELD of CordRep
+ char storage[1]; // Starting point for flat array: MUST BE LAST FIELD
inline CordRepConcat* concat();
inline const CordRepConcat* concat() const;
@@ -219,8 +219,8 @@ struct CordRepConcat : public CordRep {
CordRep* left;
CordRep* right;
- uint8_t depth() const { return static_cast<uint8_t>(data[0]); }
- void set_depth(uint8_t depth) { data[0] = static_cast<char>(depth); }
+ uint8_t depth() const { return static_cast<uint8_t>(storage[0]); }
+ void set_depth(uint8_t depth) { storage[0] = static_cast<char>(depth); }
};
struct CordRepSubstring : public CordRep {