diff options
Diffstat (limited to 'absl/strings')
-rw-r--r-- | absl/strings/BUILD.bazel | 1 | ||||
-rw-r--r-- | absl/strings/cord.h | 2 | ||||
-rw-r--r-- | absl/strings/internal/cord_internal.h | 44 |
3 files changed, 26 insertions, 21 deletions
diff --git a/absl/strings/BUILD.bazel b/absl/strings/BUILD.bazel index 794cf43a..5efaf896 100644 --- a/absl/strings/BUILD.bazel +++ b/absl/strings/BUILD.bazel @@ -286,6 +286,7 @@ cc_library( "//absl/base:base_internal", "//absl/base:config", "//absl/base:core_headers", + "//absl/base:endian", "//absl/base:raw_logging_internal", "//absl/base:throw_delegate", "//absl/container:compressed_tuple", diff --git a/absl/strings/cord.h b/absl/strings/cord.h index 17341bda..aefb5e53 100644 --- a/absl/strings/cord.h +++ b/absl/strings/cord.h @@ -289,7 +289,7 @@ class Cord { bool StartsWith(const Cord& rhs) const; bool StartsWith(absl::string_view rhs) const; - // Cord::EndsWidth() + // Cord::EndsWith() // // Determines whether the Cord ends with the passed string data `rhs`. bool EndsWith(absl::string_view rhs) const; diff --git a/absl/strings/internal/cord_internal.h b/absl/strings/internal/cord_internal.h index 96502433..cda00a44 100644 --- a/absl/strings/internal/cord_internal.h +++ b/absl/strings/internal/cord_internal.h @@ -22,6 +22,7 @@ #include <type_traits> #include "absl/base/config.h" +#include "absl/base/internal/endian.h" #include "absl/base/internal/invoke.h" #include "absl/base/optimization.h" #include "absl/container/internal/compressed_tuple.h" @@ -32,6 +33,8 @@ namespace absl { ABSL_NAMESPACE_BEGIN namespace cord_internal { +class CordzInfo; + // Default feature enable states for cord ring buffers enum CordFeatureDefaults { kCordEnableRingBufferDefault = false, @@ -193,26 +196,7 @@ struct CordRep { // -------------------------------------------------------------------- // Memory management - // This internal routine is called from the cold path of Unref below. Keeping - // it in a separate routine allows good inlining of Unref into many profitable - // call sites. However, the call to this function can be highly disruptive to - // the register pressure in those callers. To minimize the cost to callers, we - // use a special LLVM calling convention that preserves most registers. This - // allows the call to this routine in cold paths to not disrupt the caller's - // register pressure. This calling convention is not available on all - // platforms; we intentionally allow LLVM to ignore the attribute rather than - // attempting to hardcode the list of supported platforms. -#if defined(__clang__) && !defined(__i386__) -#if !(defined(ABSL_HAVE_MEMORY_SANITIZER) || \ - defined(ABSL_HAVE_THREAD_SANITIZER) || \ - defined(ABSL_HAVE_ADDRESS_SANITIZER) || \ - defined(UNDEFINED_BEHAVIOR_SANITIZER)) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wattributes" - __attribute__((preserve_most)) -#pragma clang diagnostic pop -#endif // *_SANITIZER -#endif + // Destroys the provided `rep`. static void Destroy(CordRep* rep); // Increments the reference count of `rep`. @@ -383,6 +367,26 @@ class InlineData { return as_tree_.cordz_info != kNullCordzInfo; } + // Returns the cordz_info sampling instance for this instance, or nullptr + // if the current instance is not sampled and does not have CordzInfo data. + // Requires the current instance to hold a tree value. + CordzInfo* cordz_info() const { + assert(is_tree()); + intptr_t info = + static_cast<intptr_t>(absl::big_endian::ToHost64(as_tree_.cordz_info)); + assert(info & 1); + return reinterpret_cast<CordzInfo*>(info - 1); + } + + // Sets the current cordz_info sampling instance for this instance, or nullptr + // if the current instance is not sampled and does not have CordzInfo data. + // Requires the current instance to hold a tree value. + void set_cordz_info(CordzInfo* cordz_info) { + assert(is_tree()); + intptr_t info = reinterpret_cast<intptr_t>(cordz_info) | 1; + as_tree_.cordz_info = absl::big_endian::FromHost64(info); + } + // Returns a read only pointer to the character data inside this instance. // Requires the current instance to hold inline data. const char* as_chars() const { |