From a5982f86054a5574bdf11e49c2b874cc0133cedd Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 14 Nov 2020 17:15:35 +0100 Subject: [PATCH] AK: Mark SimpleIterator::operator*() as ALWAYS_INLINE This gives the compiler enough information to optimize index validation when using range-for to iterate over a Vector, drastically reducing the cost of such loops. --- AK/Iterator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AK/Iterator.h b/AK/Iterator.h index 1d424b46709..a0e0b6a7ecc 100644 --- a/AK/Iterator.h +++ b/AK/Iterator.h @@ -72,8 +72,8 @@ public: return SimpleIterator { m_container, m_index + 1 }; } - constexpr const ValueType& operator*() const { return m_container[m_index]; } - constexpr ValueType& operator*() { return m_container[m_index]; } + ALWAYS_INLINE constexpr const ValueType& operator*() const { return m_container[m_index]; } + ALWAYS_INLINE constexpr ValueType& operator*() { return m_container[m_index]; } constexpr const ValueType* operator->() const { return &m_container[m_index]; } constexpr ValueType* operator->() { return &m_container[m_index]; }