summaryrefslogtreecommitdiff
path: root/absl/strings/cord.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2021-04-28 11:49:29 -0700
committerGravatar Derek Mauro <dmauro@google.com>2021-04-28 15:09:58 -0400
commitf14d5f4af12eb521a5142151d6ea3addbbed42bb (patch)
tree526a1feb786c03f64ed29f97d395b18480311dac /absl/strings/cord.h
parentbcc11a8918f8cc9b43c9a0dc5da7b52d48452bd3 (diff)
Export of internal Abseil changes
-- a78c34c705b15598ea00171d4ff8755e38fad863 by Derek Mauro <dmauro@google.com>: Improve compiler support for ABSL_FALLTHROUGH_INTENDED PiperOrigin-RevId: 370952333 -- aed0c26f1a2aac98e217ad1b44ce4a858780a223 by Martijn Vels <mvels@google.com>: Add Cordz instrumentation for Flatten PiperOrigin-RevId: 370815149 -- ff4a58d0109d39dc32ef7a5e5e669ca4e630c6d9 by Martijn Vels <mvels@google.com>: Add Cordz instrumentation to RemovePrefix and RemoveSuffix PiperOrigin-RevId: 370751602 -- 40220a058b30ddd89c6e547591488d15342137dd by Martijn Vels <mvels@google.com>: Add Cordz instrumentation to operator=(string_view) PiperOrigin-RevId: 370737600 -- a2e49604f18b92e50b179b5477dfddb8f57538ca by Martijn Vels <mvels@google.com>: Add cordz instrumentation for Subcord PiperOrigin-RevId: 370724107 -- bcc3902e04fb4f14270aef00e18908e6a88474cd by Derek Mauro <dmauro@google.com>: Internal change PiperOrigin-RevId: 370707219 GitOrigin-RevId: a78c34c705b15598ea00171d4ff8755e38fad863 Change-Id: I0270e536cbdeaf1f195199da822b314521de3b96
Diffstat (limited to 'absl/strings/cord.h')
-rw-r--r--absl/strings/cord.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/absl/strings/cord.h b/absl/strings/cord.h
index d5a13b34..d7b43247 100644
--- a/absl/strings/cord.h
+++ b/absl/strings/cord.h
@@ -692,6 +692,10 @@ class Cord {
// called by Flatten() when the cord was not already flat.
absl::string_view FlattenSlowPath();
+ // Copies `new_size` bytes starting at `pos` into `dest`. Requires at least
+ // `new_size` bytes to be available, and `new_size` to be <= kMaxInline.
+ void CopyDataAtPosition(size_t pos, size_t new_size, char* dest) const;
+
// Actual cord contents are hidden inside the following simple
// class so that we can isolate the bulk of cord.cc from changes
// to the representation.
@@ -745,12 +749,21 @@ class Cord {
// the CordzInfo instance is updated to reference the new `rep` value.
void SetTree(CordRep* rep, const CordzUpdateScope& scope);
+ // Identical to SetTree(), except that `rep` is allowed to be null, in
+ // which case the current instance is reset to an empty value.
+ void SetTreeOrEmpty(CordRep* rep, const CordzUpdateScope& scope);
+
// Sets the tree value for this instance, and randomly samples this cord.
// This function disregards existing contents in `data_`, and should be
// called when a Cord is 'promoted' from an 'uninitialized' or 'inlined'
// value to a non-inlined (tree / ring) value.
void EmplaceTree(CordRep* rep, MethodIdentifier method);
+ // Identical to EmplaceTree, except that it copies the parent stack from
+ // the provided `parent` data if the parent is sampled.
+ void EmplaceTree(CordRep* rep, const InlineData& parent,
+ MethodIdentifier method);
+
// Commits the change of a newly created, or updated `rep` root value into
// this cord. `old_rep` indicates the old (inlined or tree) value of the
// cord, and determines if the commit invokes SetTree() or EmplaceTree().
@@ -1071,6 +1084,12 @@ inline void Cord::InlineRep::EmplaceTree(CordRep* rep,
CordzInfo::MaybeTrackCord(data_, method);
}
+inline void Cord::InlineRep::EmplaceTree(CordRep* rep, const InlineData& parent,
+ MethodIdentifier method) {
+ data_.make_tree(rep);
+ CordzInfo::MaybeTrackCord(data_, parent, method);
+}
+
inline void Cord::InlineRep::SetTree(CordRep* rep,
const CordzUpdateScope& scope) {
assert(rep);
@@ -1079,6 +1098,17 @@ inline void Cord::InlineRep::SetTree(CordRep* rep,
scope.SetCordRep(rep);
}
+inline void Cord::InlineRep::SetTreeOrEmpty(CordRep* rep,
+ const CordzUpdateScope& scope) {
+ assert(data_.is_tree());
+ if (rep) {
+ data_.set_tree(rep);
+ } else {
+ data_ = {};
+ }
+ scope.SetCordRep(rep);
+}
+
inline void Cord::InlineRep::CommitTree(const CordRep* old_rep, CordRep* rep,
const CordzUpdateScope& scope,
MethodIdentifier method) {