diff options
author | 2020-10-19 15:25:26 -0700 | |
---|---|---|
committer | 2020-10-19 19:24:23 -0400 | |
commit | 4b915e70929ca2d6152240facc83d3d38c5d5f28 (patch) | |
tree | 3663ad6f3ddb8f0a94045bac592901ee7298447e /absl/strings/cord.h | |
parent | 8f1c34a77a2ba04512b7f9cbc6013d405e6a0b31 (diff) |
Export of internal Abseil changes
--
77c85460dc3c46593b231c5161ac55273bb0c7ef by Abseil Team <absl-team@google.com>:
Support int128 in SimpleAtoi.
PiperOrigin-RevId: 337946262
--
0be53049ccf8309650e4e22f23b290e5f75ee828 by Gennadiy Rozental <rogeeff@google.com>:
Update build scripts to use --mount instead of --volume to mount the host data into a container.
This is somewhat more verbose, but more readable and flexible. More importantly this is what docker documentation is recomending to use now.
PiperOrigin-RevId: 337898761
--
3bc877f1679fdf61ecbf4365287a0403cfc9b53e by Samuel Benzaquen <sbenza@google.com>:
Add Cord constructor for constinit instances.
PiperOrigin-RevId: 337871148
--
8b87701892b9c325e78ad4e8e4f16b785a744622 by Chris Kennelly <ckennelly@google.com>:
Use the address of kSeed, rather than its value.
We initialize kSeed with &kSeed, so these are equivalent, but kSeed requires a
load from memory while &kSeed can be formed as a RIP-relative lea.
PiperOrigin-RevId: 337868415
GitOrigin-RevId: 77c85460dc3c46593b231c5161ac55273bb0c7ef
Change-Id: I3d06c18a123f1be29dad5801e8625952dc41cd95
Diffstat (limited to 'absl/strings/cord.h')
-rw-r--r-- | absl/strings/cord.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/absl/strings/cord.h b/absl/strings/cord.h index 653a1181..5d5c897e 100644 --- a/absl/strings/cord.h +++ b/absl/strings/cord.h @@ -79,6 +79,7 @@ #include "absl/meta/type_traits.h" #include "absl/strings/internal/cord_internal.h" #include "absl/strings/internal/resize_uninitialized.h" +#include "absl/strings/internal/string_constant.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" @@ -624,6 +625,14 @@ class Cord { return c.HashFragmented(std::move(hash_state)); } + // Create a Cord with the contents of StringConstant<T>::value. + // No allocations will be done and no data will be copied. + // This is an INTERNAL API and subject to change or removal. This API can only + // be used by spelling absl::strings_internal::MakeStringConstant, which is + // also an internal API. + template <typename T> + explicit constexpr Cord(strings_internal::StringConstant<T>); + private: friend class CordTestPeer; friend bool operator==(const Cord& lhs, const Cord& rhs); @@ -655,6 +664,8 @@ class Cord { InlineRep& operator=(const InlineRep& src); InlineRep& operator=(InlineRep&& src) noexcept; + explicit constexpr InlineRep(cord_internal::InlineData data); + void Swap(InlineRep* rhs); bool empty() const; size_t size() const; @@ -884,6 +895,9 @@ Cord MakeCordFromExternal(absl::string_view data, Releaser&& releaser) { return cord; } +constexpr Cord::InlineRep::InlineRep(cord_internal::InlineData data) + : data_(data) {} + inline Cord::InlineRep::InlineRep(const Cord::InlineRep& src) { data_ = src.data_; } @@ -981,6 +995,18 @@ inline void Cord::InlineRep::CopyToArray(char* dst) const { constexpr inline Cord::Cord() noexcept {} +template <typename T> +constexpr Cord::Cord(strings_internal::StringConstant<T>) + : contents_(strings_internal::StringConstant<T>::value.size() <= + cord_internal::kMaxInline + ? cord_internal::InlineData( + strings_internal::StringConstant<T>::value) + : cord_internal::InlineData(cord_internal::AsTree{ + &cord_internal::ConstInitExternalStorage< + strings_internal::StringConstant<T>>::value, + {}, + cord_internal::kTreeFlag})) {} + inline Cord& Cord::operator=(const Cord& x) { contents_ = x.contents_; return *this; |