AK: Add an optional starting offset to CircularBuffer::offset_of

This parameter allows to start searching after an offset. For example,
to resume a search.

It is unfortunately a breaking change in API so this patch also modifies
one user and one test.
This commit is contained in:
Lucas CHOLLET 2023-01-07 13:09:20 -05:00 committed by Andrew Kaster
commit 9a7accddb7
Notes: sideshowbarker 2024-07-17 12:02:22 +09:00
4 changed files with 57 additions and 9 deletions

View file

@ -719,7 +719,7 @@ public:
Optional<size_t> longest_match;
size_t match_size = 0;
for (auto& candidate : candidates) {
auto const result = m_buffer.offset_of(candidate, readable_size);
auto const result = m_buffer.offset_of(candidate, {}, readable_size);
if (result.has_value()) {
auto previous_match = longest_match.value_or(*result);
if ((previous_match < *result) || (previous_match == *result && match_size < candidate.length())) {