// Copyright 2021 The Abseil Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "absl/strings/internal/cord_rep_btree_navigator.h" #include <cassert> #include "absl/strings/internal/cord_data_edge.h" #include "absl/strings/internal/cord_internal.h" #include "absl/strings/internal/cord_rep_btree.h" namespace absl { ABSL_NAMESPACE_BEGIN namespace cord_internal { ReadResult; namespace { // Returns a `CordRepSubstring` from `rep` starting at `offset` of size `n`. // If `rep` is already a `CordRepSubstring` instance, an adjusted instance is // created based on the old offset and new offset. // Adopts a reference on `rep`. Rep must be a valid data edge. Returns // nullptr if `n == 0`, `rep` if `n == rep->length`. // Requires `offset < rep->length` and `offset + n <= rep->length`. // TODO(192061034): move to utility library in internal and optimize for small // substrings of larger reps. inline CordRep* Substring(CordRep* rep, size_t offset, size_t n) { … } inline CordRep* Substring(CordRep* rep, size_t offset) { … } } // namespace CordRepBtreeNavigator::Position CordRepBtreeNavigator::Skip(size_t n) { … } ReadResult CordRepBtreeNavigator::Read(size_t edge_offset, size_t n) { … } } // namespace cord_internal ABSL_NAMESPACE_END } // namespace absl