-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
ExternalRef
, which specifies a byte array in a way which allows…
… sharing it with other objects without copying if that is considered more efficient than copying. It mediates between the producer and the consumer of the data during transfer; it is not suitable for longer storage. Creating an `ExternalRef` is usually more efficient than creating a `Chain` or `absl::Cord` if the data will ultimately be copied rather than shared. `{,Backward}Writer::Write(ExternalRef)` replace `{,Backward}Writer::SupportsCopying()` as a mechanism to choose between copying and sharing. At the same time the mechanism is extended with allowing a preference to producing `absl::Cord` or a pointer with a deleter. Add `ExternalStorage` alias for specifying a pointer with a deleter, and `ExternalData` struct for specifying that together with a substring of a byte array it owns. Add `{Chain::BlockIterator,Buffer,SharedBuffer,SizedSharedBuffer,CompactString}::ToExternalRef()` to wrap typical usages of the `ExternalRef` constructor. Remove functionality subsumed by `ExternalRef`: * `Buffer::{Release,DeleteReleased}()` * `SharedBuffer::{Share,DeleteShared}()` * `{Buffer,SharedBuffer}::{ToCord,AppendSubstrTo,PrependSubstrTo}()` * `SizedSharedBuffer::{Substr,storage,operator absl::Cord,AppendTo,PrependTo}()` * `Chain::{Chain,Append,Prepend}(SizedSharedBuffer)` * `Chain::BlockIterator::Pin()` with `Chain::PinnedBlock` * `Chain::BlockIterator::{Append,Prepend}{,Substr}To()` * `Chain::RawBlock::{Append,Prepend}{,Substr}To()` (internal) * `FlatCordRef::{Append,Prepend}{,Substr}To()` (internal) * `SharedBufferRef` (internal) Remove publicly unused and not publicly useful `SizedSharedBuffer::IsUnique()`. Tweak conditions for choosing between copying and sharing across classes to be more uniform. In particular prefer sharing if the size hint indicates that this is the last write, or the current position is 0 in absence of a size hint which indicates that this is the first and perhaps the only write, i.e. the data being written will more likely not be concatenated with other data. Split `chain.h` to `chain_base.h` and `chain_details.h` because of mutual dependency betewen `Chain` and `ExternalRef`. Minor changes: * Change the split of responsibility between the fast path of `{,Backward}Writer::Write(std::string&&)` and `WriteStringSlow()` so that the fast path covers a short string only when it fits in the buffer. * In `Chain::FromExternal()` which converts the data from the object, require the conversion to `absl::string_view` to be const. This makes the expected interface for `ExternalRef` a superset of the interface for `Chain::FromExeternal()`. In practice it is unlikely that such a conversion might benefit from being non-const. * Rename the `absl::string_view data` parameter of functions associated with external objects with `absl::string_view substr`, to highlight that it might represent a substring of the owned data. PiperOrigin-RevId: 646086366
- Loading branch information
Showing
88 changed files
with
4,621 additions
and
3,143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.