mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
AK: Inline busy functions in Vector
This commit is contained in:
parent
dace14e70d
commit
d0106c129a
Notes:
sideshowbarker
2024-07-19 07:04:07 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/d0106c129ab Pull-request: https://github.com/SerenityOS/serenity/pull/1661 Reviewed-by: https://github.com/Dexesttp Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/itamar8910
18
AK/Vector.h
18
AK/Vector.h
@ -250,7 +250,7 @@ public:
|
||||
// NOTE: Vector::is_null() exists for the benefit of String::copy().
|
||||
bool is_null() const { return false; }
|
||||
bool is_empty() const { return size() == 0; }
|
||||
size_t size() const { return m_size; }
|
||||
ALWAYS_INLINE size_t size() const { return m_size; }
|
||||
size_t capacity() const { return m_capacity; }
|
||||
|
||||
T* data()
|
||||
@ -266,19 +266,19 @@ public:
|
||||
return m_outline_buffer;
|
||||
}
|
||||
|
||||
const T& at(size_t i) const
|
||||
ALWAYS_INLINE const T& at(size_t i) const
|
||||
{
|
||||
ASSERT(i >= 0 && i < m_size);
|
||||
return data()[i];
|
||||
}
|
||||
T& at(size_t i)
|
||||
ALWAYS_INLINE T& at(size_t i)
|
||||
{
|
||||
ASSERT(i >= 0 && i < m_size);
|
||||
return data()[i];
|
||||
}
|
||||
|
||||
const T& operator[](size_t i) const { return at(i); }
|
||||
T& operator[](size_t i) { return at(i); }
|
||||
ALWAYS_INLINE const T& operator[](size_t i) const { return at(i); }
|
||||
ALWAYS_INLINE T& operator[](size_t i) { return at(i); }
|
||||
|
||||
const T& first() const { return at(0); }
|
||||
T& first() { return at(0); }
|
||||
@ -437,14 +437,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void unchecked_append(T&& value)
|
||||
ALWAYS_INLINE void unchecked_append(T&& value)
|
||||
{
|
||||
ASSERT((size() + 1) <= capacity());
|
||||
new (slot(m_size)) T(move(value));
|
||||
++m_size;
|
||||
}
|
||||
|
||||
void unchecked_append(const T& value)
|
||||
ALWAYS_INLINE void unchecked_append(const T& value)
|
||||
{
|
||||
unchecked_append(T(value));
|
||||
}
|
||||
@ -457,14 +457,14 @@ public:
|
||||
++m_size;
|
||||
}
|
||||
|
||||
void append(T&& value)
|
||||
ALWAYS_INLINE void append(T&& value)
|
||||
{
|
||||
grow_capacity(size() + 1);
|
||||
new (slot(m_size)) T(move(value));
|
||||
++m_size;
|
||||
}
|
||||
|
||||
void append(const T& value)
|
||||
ALWAYS_INLINE void append(const T& value)
|
||||
{
|
||||
append(T(value));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user