-
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.
Let types explicitly indicate support for being passed to
ExternalRef
constructors: `RiegeliSupportsExternalRef()` and `RiegeliSupportsExternalRefWhole()`. They also indicate whether their substrings are stable when the object is moved, and whether passing a copy of an object is more efficient than copying the data. `ExternalRef::From()` are like `ExternalRef` constructors, but `RiegeliSupportsExternalRef()` or `RiegeliSupportsExternalRefWhole()` is not needed. The caller is responsible for using an appropriate type of the external object. This mechanism replaces `ToExternalRef()` member functions in several classes, and opts certain types into it. A uniform mechanism allows certain functions to wrap objects in `ExternalRef` automatically. Also, callers are not forced to remember whether specifying `substr` is valid for the moved object (this property differs e.g. between `std::string` and `std::vector<char>`). Allow types to provide a predicate for objects whose data must be copied, e.g. because it is stored inline: `RiegeliExternalCopy()`. Remove `ExternalRef` constructor which always makes a copy. This is no longer needed given `RiegeliExternalCopy()`. Call `RiegeliTo{ChainBlock,Cord,ExternalData}(T*, substr)` if defined with `substr` also when `ExternalRef` constructor was called without `substr`. Allow types to provide a function which indicates that a subobject should be wrapped instead: `RiegeliExternalDelegate()`. Express appending `ExternalRef` to `Chain` as `Chain::Append(ExternalRef)` instead of `ExternalRef::AppendTo(Chain&)`. Same for prepending. This is inconsistent with `Cord` but is more natural in isolation, and allows for automatic wrapping of objects in `ExternalRef` (see below). Convert data to `ExternalRef` automatically when this is indicated as supported in `{,Backward}Writer::Write()` and in conversions to `Chain`. Add `Chain::Reset(ExternalRef)` and optimize the behavior of `riegeli::Reset(Cord&, ExternalRef)`. Do not bother including the overhead of wrapper objects when checking whether wrapping an object would be wasteful, for simplicity. This was inaccurate anyway when `RiegeliTo{ChainBlock,Cord,ExternalData}()` is used. Add assertions that the specified substring of an external object is indeed a substring if the object supports `riegeli::ToStringView()`. Change `Chain::BlockIterator` to yield a new type `Chain::BlockRef` instead of `absl::string_view`. This allows conversion to `ExternalRef` to be defined on `Chain::BlockRef` rather than `Chain::BlockIterator`, which works also when iterators are implicit in a `for` loop. PiperOrigin-RevId: 658318102
- Loading branch information
Showing
47 changed files
with
2,150 additions
and
1,150 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
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.