diff options
author | vadim-xd <vadim-xd@yandex-team.com> | 2024-09-23 23:25:21 +0300 |
---|---|---|
committer | vadim-xd <vadim-xd@yandex-team.com> | 2024-09-23 23:35:43 +0300 |
commit | 53f13049cb8f79b2b6ac95251fd6a03e4b8c7ba2 (patch) | |
tree | d0c3f58c0e8d4c11c742a339279e3ea29eb764e7 | |
parent | f377199cf3b6a29f5eee520a969ef7ba243f61a9 (diff) | |
download | ydb-53f13049cb8f79b2b6ac95251fd6a03e4b8c7ba2.tar.gz |
Implement uninitialized string resize in abseil-cpp-tstring
commit_hash:b627b33a30b4948b8b2240e7aa8693793e86501f
-rw-r--r-- | contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/resize_uninitialized.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/resize_uninitialized.h b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/resize_uninitialized.h index 984562257d..8451cc504b 100644 --- a/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/resize_uninitialized.h +++ b/contrib/restricted/abseil-cpp-tstring/y_absl/strings/internal/resize_uninitialized.h @@ -49,6 +49,16 @@ struct ResizeUninitializedTraits< } }; +template <typename string_type> +struct ResizeUninitializedTraits< + string_type, y_absl::void_t<decltype(std::declval<string_type&>() + .ReserveAndResize(237))> > { + using HasMember = std::true_type; + static void Resize(string_type* s, size_t new_size) { + s->ReserveAndResize(new_size); + } +}; + // Returns true if the TString implementation supports a resize where // the new characters added to the TString are left untouched. // @@ -98,6 +108,15 @@ struct AppendUninitializedTraits< } }; +template <typename string_type> +struct AppendUninitializedTraits< + string_type, y_absl::void_t<decltype(std::declval<string_type&>() + .ReserveAndResize(237))> > { + static void Append(string_type* s, size_t n) { + s->ReserveAndResize(s->size() + n); + } +}; + // Like STLStringResizeUninitialized(str, new_size), except guaranteed to use // exponential growth so that the amortized complexity of increasing the string // size by a small amount is O(1), in contrast to O(str->size()) in the case of |