mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
AK: Properly limit the internal seekback span for CircularBuffer
I was originally thinking in the wrong direction when adding this limit, we can at most read from the buffer until we reach the current write head. Since that write head is the reference point for the distance, we need to limit ourselves to that instead of the seekback limit (which is the maximum of how far back the distance can be).
This commit is contained in:
parent
09dd9c4fad
commit
997e745e87
Notes:
sideshowbarker
2024-07-17 08:25:15 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/997e745e87 Pull-request: https://github.com/SerenityOS/serenity/pull/18180 Reviewed-by: https://github.com/gmta Reviewed-by: https://github.com/trflynn89 ✅
@ -110,7 +110,7 @@ ReadonlyBytes CircularBuffer::next_read_span_with_seekback(size_t distance) cons
|
||||
// Note: We are adding the capacity once here to ensure that we can wrap around the negative space by using modulo.
|
||||
auto read_offset = (capacity() + m_reading_head + m_used_space - distance) % capacity();
|
||||
|
||||
return m_buffer.span().slice(read_offset, min(capacity() - read_offset, m_seekback_limit));
|
||||
return m_buffer.span().slice(read_offset, min(capacity() - read_offset, distance));
|
||||
}
|
||||
|
||||
size_t CircularBuffer::write(ReadonlyBytes bytes)
|
||||
|
Loading…
Reference in New Issue
Block a user