mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-05 01:10:24 +00:00
AK: Introduce Vector::unchecked_empend()
This does the same thing as `Vector::empend()` without attempting to grow the underlying buffer.
This commit is contained in:
committed by
Tim Ledbetter
parent
f675cfe90f
commit
c1742fa989
Notes:
github-actions[bot]
2025-11-26 14:35:34 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/c1742fa9898 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6938 Reviewed-by: https://github.com/alimpfard ✅
21
AK/Vector.h
21
AK/Vector.h
@@ -382,6 +382,27 @@ public:
|
||||
MUST(try_empend(forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<class... Args>
|
||||
ALWAYS_INLINE void unchecked_empend(Args&&... args)
|
||||
requires(!contains_reference)
|
||||
{
|
||||
VERIFY(m_size < capacity());
|
||||
if constexpr (want_fast_last_access) {
|
||||
++m_metadata.last_slot;
|
||||
++m_size;
|
||||
} else {
|
||||
++m_size;
|
||||
}
|
||||
|
||||
StorageType* last_slot;
|
||||
if constexpr (want_fast_last_access)
|
||||
last_slot = m_metadata.last_slot;
|
||||
else
|
||||
last_slot = slot(m_size - 1);
|
||||
|
||||
new (last_slot) StorageType(forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<typename U = T>
|
||||
void prepend(U&& value)
|
||||
requires(CanBePlacedInsideVector<U>)
|
||||
|
||||
Reference in New Issue
Block a user