You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Merge pull request #72056 from resistor/master
[GDScript] Perform update-and-assign operations in place when possible.
This commit is contained in:
@@ -1165,8 +1165,18 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
|
|||||||
bool has_operation = assignment->operation != GDScriptParser::AssignmentNode::OP_NONE;
|
bool has_operation = assignment->operation != GDScriptParser::AssignmentNode::OP_NONE;
|
||||||
if (has_operation) {
|
if (has_operation) {
|
||||||
// Perform operation.
|
// Perform operation.
|
||||||
GDScriptCodeGenerator::Address op_result = codegen.add_temporary(_gdtype_from_datatype(assignment->get_datatype(), codegen.script));
|
|
||||||
GDScriptCodeGenerator::Address og_value = _parse_expression(codegen, r_error, assignment->assignee);
|
GDScriptCodeGenerator::Address og_value = _parse_expression(codegen, r_error, assignment->assignee);
|
||||||
|
|
||||||
|
if (!has_setter && !assignment->use_conversion_assign) {
|
||||||
|
// If there's nothing special about the assignment, perform the assignment as part of the operator
|
||||||
|
gen->write_binary_operator(target, assignment->variant_op, og_value, assigned_value);
|
||||||
|
if (assigned_value.mode == GDScriptCodeGenerator::Address::TEMPORARY) {
|
||||||
|
gen->pop_temporary(); // Pop assigned value if not done before.
|
||||||
|
}
|
||||||
|
return GDScriptCodeGenerator::Address();
|
||||||
|
}
|
||||||
|
|
||||||
|
GDScriptCodeGenerator::Address op_result = codegen.add_temporary(_gdtype_from_datatype(assignment->get_datatype(), codegen.script));
|
||||||
gen->write_binary_operator(op_result, assignment->variant_op, og_value, assigned_value);
|
gen->write_binary_operator(op_result, assignment->variant_op, og_value, assigned_value);
|
||||||
to_assign = op_result;
|
to_assign = op_result;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user