aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4runtime_p.h
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2015-08-03 12:02:52 +0200
committerErik Verbruggen <erik.verbruggen@theqtcompany.com>2015-08-06 07:15:46 +0000
commitc88471ee7e8eb7c4351e29bf0e6fe45b96da8168 (patch)
tree2179e45b49e18f35fff27571fc1fcb7a4bc8e032 /src/qml/jsruntime/qv4runtime_p.h
parentcb182b46cdbf2fa166bd584afefb07fa90c2b6df (diff)
V4: add int32 codepath to Runtime::div.
Mirrors Runtime::mod, and prevents unnecessary conversion to double. Change-Id: Ib550ed3bc31aaf5bc5fd53524b396cce154d20a9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime_p.h')
-rw-r--r--src/qml/jsruntime/qv4runtime_p.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4runtime_p.h b/src/qml/jsruntime/qv4runtime_p.h
index f825732a6c..c2a0b5ec48 100644
--- a/src/qml/jsruntime/qv4runtime_p.h
+++ b/src/qml/jsruntime/qv4runtime_p.h
@@ -370,6 +370,15 @@ inline ReturnedValue Runtime::div(const Value &left, const Value &right)
{
TRACE2(left, right);
+ if (Value::integerCompatible(left, right)) {
+ int lval = left.integerValue();
+ int rval = right.integerValue();
+ if (rval != 0 && (lval % rval == 0))
+ return Encode(int(lval / rval));
+ else
+ return Encode(double(lval) / rval);
+ }
+
double lval = left.toNumber();
double rval = right.toNumber();
return Primitive::fromDouble(lval / rval).asReturnedValue();