mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibJS: Use memmove in Object::indexed_take_first()
The element-by-element loop compiled to scalar 8-byte moves that the compiler could not vectorize: source and destination alias, and strict aliasing prevented hoisting the m_indexed_elements pointer load out of the loop body. memmove collapses the shift into a single vectorized copy.
This commit is contained in:
committed by
Andreas Kling
parent
3d3b02b9c0
commit
ad7177eccb
Notes:
github-actions[bot]
2026-04-23 19:48:29 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/ad7177eccb8 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/9059
@@ -2007,9 +2007,8 @@ ValueAndAttributes Object::indexed_take_first()
|
||||
auto available_elements = min(m_indexed_array_like_size, indexed_elements_capacity());
|
||||
auto first = available_elements > 0 ? m_indexed_elements[0] : js_special_empty_value();
|
||||
|
||||
// Shift all elements left
|
||||
for (u32 i = 0; i + 1 < available_elements; ++i)
|
||||
m_indexed_elements[i] = m_indexed_elements[i + 1];
|
||||
if (available_elements > 1)
|
||||
memmove(m_indexed_elements, m_indexed_elements + 1, (available_elements - 1) * sizeof(Value));
|
||||
|
||||
m_indexed_array_like_size--;
|
||||
if (available_elements > 0)
|
||||
|
||||
Reference in New Issue
Block a user