mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibJS/Bytecode: Allow assignment expression to write directly to locals
This commit is contained in:
parent
d22a06d671
commit
ce7c925924
Notes:
sideshowbarker
2024-07-17 01:55:29 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ce7c925924 Pull-request: https://github.com/SerenityOS/serenity/pull/24324
1 changed files with 6 additions and 1 deletions
|
@ -642,7 +642,12 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> AssignmentExpression::g
|
|||
return TRY(m_rhs->generate_bytecode(generator)).value();
|
||||
}());
|
||||
|
||||
auto dst = choose_dst(generator, preferred_dst);
|
||||
// OPTIMIZATION: If LHS is a local, we can write the result directly into it.
|
||||
auto dst = [&] {
|
||||
if (lhs.operand().is_local())
|
||||
return lhs;
|
||||
return choose_dst(generator, preferred_dst);
|
||||
}();
|
||||
|
||||
switch (m_op) {
|
||||
case AssignmentOp::AdditionAssignment:
|
||||
|
|
Loading…
Reference in a new issue