mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibJS: Remember the position into the cached indices
There is no need to do a full linear search from start to end when we can just remember the position and continue where we left off.
This commit is contained in:
parent
2bd43e3603
commit
f4e2476284
Notes:
github-actions[bot]
2024-11-03 10:27:19 +00:00
Author: https://github.com/yyny Commit: https://github.com/LadybirdBrowser/ladybird/commit/f4e24762846 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2129
2 changed files with 6 additions and 3 deletions
|
@ -210,10 +210,12 @@ bool IndexedPropertyIterator::operator!=(IndexedPropertyIterator const& other) c
|
|||
|
||||
void IndexedPropertyIterator::skip_empty_indices()
|
||||
{
|
||||
for (auto i : m_cached_indices) {
|
||||
if (i < m_index)
|
||||
for (size_t i = m_next_cached_index; i < m_cached_indices.size(); i++) {
|
||||
auto index = m_cached_indices[i];
|
||||
if (index < m_index)
|
||||
continue;
|
||||
m_index = i;
|
||||
m_index = index;
|
||||
m_next_cached_index = i + 1;
|
||||
return;
|
||||
}
|
||||
m_index = m_indexed_properties.array_like_size();
|
||||
|
|
|
@ -135,6 +135,7 @@ private:
|
|||
|
||||
IndexedProperties const& m_indexed_properties;
|
||||
Vector<u32> m_cached_indices;
|
||||
size_t m_next_cached_index { 0 };
|
||||
u32 m_index { 0 };
|
||||
bool m_skip_empty { false };
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue