Don't evaluate the expression in switch() multiple times
authorLars Knoll <lars.knoll@theqtcompany.com>
Mon, 9 Mar 2015 09:13:25 +0000 (10:13 +0100)
committerLars Knoll <lars.knoll@digia.com>
Wed, 11 Mar 2015 08:23:10 +0000 (08:23 +0000)
commitd1c5f134bd455c7af42a4a912e74ad0f97f21346
treeb678b0ea286337d506ddfb32c00ddcc47daee91b
parent61cfaee2d0e4ae106a00950e917b712a52049d6f
Don't evaluate the expression in switch() multiple times

The old code would evaluate the expression in the switch
statement once for every case label. This is not only slower
than it should be, but can also lead to unexpected results in
case the expression doesn't always evaluate to the same value
or has side effects.

Task-number: QTBUG-41630
Change-Id: Id93baca7e3aa09ce884967ef6524d4c4f055bcd6
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
src/qml/compiler/qv4codegen.cpp
tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp