summaryrefslogtreecommitdiff
path: root/absl/strings/string_view.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2021-03-31 20:42:07 -0700
committerGravatar Andy Getz <durandal@google.com>2021-04-01 02:36:11 -0400
commit2faed9dd2a3722eda068ad88df3b4071f5c5588d (patch)
tree867bb51c6bb4c390b4b0aa972747a5d4447e0c9a /absl/strings/string_view.h
parentd9a31a2d440f33aa40d88b3b8a98f4c19ffaa182 (diff)
Export of internal Abseil changes
-- 6cfac39ea1266f01f195de5eb4c9a6fc9ea9b20a by Matt Kulukundis <kfm@google.com>: Fix a typo PiperOrigin-RevId: 366174890 -- 6ee8c58647aef171d394e59fa06f9bf8cd0306ec by Derek Mauro <dmauro@google.com>: Adds `ABSL_ATTRIBUTE_LIFETIME_BOUND` and applies it to the `const std::string&` constructor of `absl::string_view`. Compilers that support this attribute will emit a warning if the parameter does not have sufficient lifetime. PiperOrigin-RevId: 366027738 -- b944427d96e4b436b8fa0fe396c2a1118dbbbd13 by Abseil Team <absl-team@google.com>: Calls to `ResetToEmpty()` from `ClearSlow` use ~3% of the time in assignment. However, `ClearSlow()` is only used in contexts where `data_` is immediately reassigned. Rename `ClearSlow()` into `UnrefTree()` and remove `data_` resetting. PiperOrigin-RevId: 365977213 -- 7428b3147a5672c8bb55649efa3a1cfe19b52a8b by Abseil Team <absl-team@google.com>: Fix CordRepRing diabolical growth The 'Mutable' function in CordRepRing was over-eager in doubling capacity, which lead to 'ludicrous' growth in the diabolical test case as added to cord_test. This CL fixes the doubling for growing shared reps, and tempers CordRepRing growth for non shared capacity to 1.5 instead of 2, which is more inline with a conservative growth we also have in tree cord. After this change, CordRepRing no longer swamps the heap into the shadow realm, and is in effect reducing the memory used compared to the tree implementation. With a diabolical 5000 bytes growth pattern: Tree cord: 1523520 bytes Ring cord: 274232 bytes PiperOrigin-RevId: 365915857 -- f24d4aee48b03c5a7980664df903f947cbb198e8 by Andy Getzendanner <durandal@google.com>: Import of CCTZ from GitHub. PiperOrigin-RevId: 365873932 GitOrigin-RevId: 6cfac39ea1266f01f195de5eb4c9a6fc9ea9b20a Change-Id: I9737aa215ac732c9785a1d0032c77aba62330f12
Diffstat (limited to 'absl/strings/string_view.h')
-rw-r--r--absl/strings/string_view.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/absl/strings/string_view.h b/absl/strings/string_view.h
index b276bdba..1f14a758 100644
--- a/absl/strings/string_view.h
+++ b/absl/strings/string_view.h
@@ -36,6 +36,7 @@
#include <limits>
#include <string>
+#include "absl/base/attributes.h"
#include "absl/base/config.h"
#include "absl/base/internal/throw_delegate.h"
#include "absl/base/macros.h"
@@ -180,8 +181,8 @@ class string_view {
template <typename Allocator>
string_view( // NOLINT(runtime/explicit)
- const std::basic_string<char, std::char_traits<char>, Allocator>&
- str) noexcept
+ const std::basic_string<char, std::char_traits<char>, Allocator>& str
+ ABSL_ATTRIBUTE_LIFETIME_BOUND) noexcept
// This is implemented in terms of `string_view(p, n)` so `str.size()`
// doesn't need to be reevaluated after `ptr_` is set.
: string_view(str.data(), str.size()) {}