LibWeb: Avoid shifting vector elements in get_session_history_entries()

This function essentially performs a BFS traversal over document states.
With this change, we let `doc_states` grow instead of removing traversed
states, avoiding shifting elements on every iteration.

This reduces `./test-web -j 1` from ~7m to ~5m on my machine.
This commit is contained in:
Aliaksandr Kalenik
2025-12-27 18:11:45 +01:00
committed by Andreas Kling
parent 207d82f8bc
commit 38af5d623c

View File

@@ -672,8 +672,8 @@ Vector<GC::Ref<SessionHistoryEntry>>& Navigable::get_session_history_entries() c
doc_states.append(entry->document_state());
// 6. For each docState of docStates:
while (!doc_states.is_empty()) {
auto doc_state = doc_states.take_first();
for (size_t i = 0; i < doc_states.size(); ++i) {
auto doc_state = doc_states[i];
// 1. For each nestedHistory of docState's nested histories:
for (auto& nested_history : doc_state->nested_histories()) {