mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 15:19:42 +00:00
LibJS: Optimize array destructuring assignment for builtin iterators
...by avoiding `{ value, done }` iterator result value allocation. This
change applies the same otimization 81b6a11
added for `for..in` and
`for..of`.
Makes following micro benchmark go 22% faster on my computer:
```js
function f() {
const arr = [];
for (let i = 0; i < 10_000_000; i++) {
arr.push([i]);
}
let sum = 0;
for (let [i] of arr) {
sum += i;
}
}
f();
```
This commit is contained in:
parent
295b78f7d3
commit
60bd5012fe
Notes:
github-actions[bot]
2025-05-01 13:58:54 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 60bd5012fe
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4544
4 changed files with 11 additions and 15 deletions
|
@ -2721,10 +2721,10 @@ private:
|
|||
Operand m_iterator_record;
|
||||
};
|
||||
|
||||
class ForOfNext final : public Instruction {
|
||||
class IteratorNextUnpack final : public Instruction {
|
||||
public:
|
||||
ForOfNext(Operand dst_value, Operand dst_done, Operand iterator_record)
|
||||
: Instruction(Type::ForOfNext)
|
||||
IteratorNextUnpack(Operand dst_value, Operand dst_done, Operand iterator_record)
|
||||
: Instruction(Type::IteratorNextUnpack)
|
||||
, m_dst_value(dst_value)
|
||||
, m_dst_done(dst_done)
|
||||
, m_iterator_record(iterator_record)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue