1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:57:44 +00:00

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
parent 34922c0cc0
commit 9a7accddb7
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())) {