mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:07:34 +00:00
LibJS: Cache valid indices in IndexedPropertyIterator
Refetching the list of indices every time we increment the iterator was showing up hot & heavy in a profile of Discord.
This commit is contained in:
parent
483dce9750
commit
0d60cf211d
2 changed files with 5 additions and 3 deletions
|
@ -177,8 +177,10 @@ IndexedPropertyIterator::IndexedPropertyIterator(const IndexedProperties& indexe
|
||||||
, m_index(staring_index)
|
, m_index(staring_index)
|
||||||
, m_skip_empty(skip_empty)
|
, m_skip_empty(skip_empty)
|
||||||
{
|
{
|
||||||
if (m_skip_empty)
|
if (m_skip_empty) {
|
||||||
|
m_cached_indices = m_indexed_properties.indices();
|
||||||
skip_empty_indices();
|
skip_empty_indices();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexedPropertyIterator& IndexedPropertyIterator::operator++()
|
IndexedPropertyIterator& IndexedPropertyIterator::operator++()
|
||||||
|
@ -203,8 +205,7 @@ bool IndexedPropertyIterator::operator!=(const IndexedPropertyIterator& other) c
|
||||||
|
|
||||||
void IndexedPropertyIterator::skip_empty_indices()
|
void IndexedPropertyIterator::skip_empty_indices()
|
||||||
{
|
{
|
||||||
auto indices = m_indexed_properties.indices();
|
for (auto i : m_cached_indices) {
|
||||||
for (auto i : indices) {
|
|
||||||
if (i < m_index)
|
if (i < m_index)
|
||||||
continue;
|
continue;
|
||||||
m_index = i;
|
m_index = i;
|
||||||
|
|
|
@ -106,6 +106,7 @@ private:
|
||||||
void skip_empty_indices();
|
void skip_empty_indices();
|
||||||
|
|
||||||
const IndexedProperties& m_indexed_properties;
|
const IndexedProperties& m_indexed_properties;
|
||||||
|
Vector<u32> m_cached_indices;
|
||||||
u32 m_index;
|
u32 m_index;
|
||||||
bool m_skip_empty;
|
bool m_skip_empty;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue