diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-01-24 11:45:47 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-01-25 14:47:22 +0000 |
commit | 898f67ca3b2b727ab7f4f4e74f10a8daed19365b (patch) | |
tree | 4182d260332d556fa12b6e5f3b14fdf49a3597bd | |
parent | 68bd6fcc8a71400138f92a6454b850104b9da88c (diff) |
Directly assign initializers to variables in variable declarations
.. instead of first assigning to a temporary and then assigning the
temporary to the argument/local.
Change-Id: I15a6c2073b78c5cfc829c7edef07c6bf48be7886
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r-- | src/qml/compiler/qv4codegen.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index d9c1e90125..7d3ad38f97 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -842,9 +842,16 @@ void Codegen::variableDeclaration(VariableDeclaration *ast) Q_ASSERT(expr.code); initializer = *expr; - int initialized = _block->newTemp(); - move(_block->TEMP(initialized), initializer); - move(identifier(ast->name.toString(), ast->identifierToken.startLine, ast->identifierToken.startColumn), _block->TEMP(initialized)); + IR::Expr *lhs = identifier(ast->name.toString(), ast->identifierToken.startLine, + ast->identifierToken.startColumn); + + if (lhs->asArgLocal()) { + move(lhs, initializer); + } else { + int initialized = _block->newTemp(); + move(_block->TEMP(initialized), initializer); + move(lhs, _block->TEMP(initialized)); + } } void Codegen::variableDeclarationList(VariableDeclarationList *ast) |