diff options
author | 2022-09-29 15:58:11 -0700 | |
---|---|---|
committer | 2022-09-29 15:58:57 -0700 | |
commit | cfa5dc7576b91147cb8a580d4baa188e57f2a362 (patch) | |
tree | 16261917c8f340e8000a2b79f16ce55a55960d7c /absl/strings/cord.h | |
parent | 40ede06edcc02fa1762bb0e445cef833f5856fba (diff) |
Cleanup some InlineData internal layout specific details from cord.h
This makes future platform specific internal layout changes easier to land.
PiperOrigin-RevId: 477843948
Change-Id: I4ca4fdea5e965261c029d08319aba0290721c227
Diffstat (limited to 'absl/strings/cord.h')
-rw-r--r-- | absl/strings/cord.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/absl/strings/cord.h b/absl/strings/cord.h index 62fcb2c6..e8267ab1 100644 --- a/absl/strings/cord.h +++ b/absl/strings/cord.h @@ -894,9 +894,8 @@ class Cord { // memcpy is much faster when operating on a known size. On most supported // platforms, the small string optimization is large enough that resizing // to 15 bytes does not cause a memory allocation. - absl::strings_internal::STLStringResizeUninitialized(dst, - sizeof(data_) - 1); - memcpy(&(*dst)[0], &data_, sizeof(data_) - 1); + absl::strings_internal::STLStringResizeUninitialized(dst, kMaxInline); + memcpy(&(*dst)[0], data_.as_chars(), kMaxInline); // erase is faster than resize because the logic for memory allocation is // not needed. dst->erase(inline_size()); @@ -1189,7 +1188,7 @@ inline cord_internal::CordRepFlat* Cord::InlineRep::MakeFlatWithExtraCapacity( size_t len = data_.inline_size(); auto* result = CordRepFlat::New(len + extra); result->length = len; - memcpy(result->Data(), data_.as_chars(), sizeof(data_)); + memcpy(result->Data(), data_.as_chars(), InlineRep::kMaxInline); return result; } |