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

AK+LibWeb: Use segmented vector to store commands in RecordingPainter

Using a vector to represent a list of painting commands results in many
reallocations, especially on pages with a lot of content.

This change addresses it by introducing a SegmentedVector, which allows
fast appending by representing a list as a sequence of fixed-size
vectors. Currently, this new data structure supports only the
operations used in RecordingPainter, which are appending and iterating.
This commit is contained in:
Aliaksandr Kalenik 2023-12-30 20:07:29 +01:00 committed by Andreas Kling
parent 97f676dbf2
commit e394971209
4 changed files with 99 additions and 1 deletions

View file

@ -8,6 +8,7 @@
#include <AK/Forward.h>
#include <AK/NonnullRefPtr.h>
#include <AK/SegmentedVector.h>
#include <AK/Utf8View.h>
#include <AK/Vector.h>
#include <LibGfx/AntiAliasingPainter.h>
@ -623,7 +624,7 @@ private:
PaintingCommand command;
};
Vector<PaintingCommandWithScrollFrame> m_painting_commands;
AK::SegmentedVector<PaintingCommandWithScrollFrame, 512> m_painting_commands;
Vector<State> m_state_stack;
};