mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 09:34:57 +09:00
AK: Split up CircularBuffer::find_copy_in_seekback
The "operation modes" of this function have very different focuses, and trying to combine both in a way where we share the most amount of code probably results in the worst performance. Instead, split up the function into "existing distances" and "no existing distances" so that we can optimize either case separately.
This commit is contained in:
parent
9e82ad758e
commit
046a9faeb3
Notes:
sideshowbarker
2024-07-17 04:34:25 +09:00
Author: https://github.com/timschumi
Commit: 046a9faeb3
Pull-request: https://github.com/SerenityOS/serenity/pull/19332
Reviewed-by: https://github.com/linusg ✅
4 changed files with 91 additions and 53 deletions
|
@ -412,7 +412,7 @@ TEST_CASE(find_copy_in_seekback)
|
|||
|
||||
{
|
||||
// Find the largest matches with a length between 1 and 2 (selected "AB", everything smaller gets eliminated).
|
||||
auto matches = MUST(buffer.find_copy_in_seekback(2, 1, Vector<size_t> { 6ul, 9ul }));
|
||||
auto matches = MUST(buffer.find_copy_in_seekback(Vector<size_t> { 6ul, 9ul }, 2, 1));
|
||||
EXPECT_EQ(matches.size(), 2ul);
|
||||
EXPECT_EQ(matches[0].distance, 6ul);
|
||||
EXPECT_EQ(matches[0].length, 2ul);
|
||||
|
@ -422,13 +422,13 @@ TEST_CASE(find_copy_in_seekback)
|
|||
|
||||
{
|
||||
// Check that we don't find anything for hints before the valid range.
|
||||
auto matches = MUST(buffer.find_copy_in_seekback(2, 1, Vector<size_t> { 0ul }));
|
||||
auto matches = MUST(buffer.find_copy_in_seekback(Vector<size_t> { 0ul }, 2, 1));
|
||||
EXPECT_EQ(matches.size(), 0ul);
|
||||
}
|
||||
|
||||
{
|
||||
// Check that we don't find anything for hints after the valid range.
|
||||
auto matches = MUST(buffer.find_copy_in_seekback(2, 1, Vector<size_t> { 12ul }));
|
||||
auto matches = MUST(buffer.find_copy_in_seekback(Vector<size_t> { 12ul }, 2, 1));
|
||||
EXPECT_EQ(matches.size(), 0ul);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue