diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2015-08-03 12:02:52 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2015-08-06 07:15:46 +0000 |
commit | c88471ee7e8eb7c4351e29bf0e6fe45b96da8168 (patch) | |
tree | 2179e45b49e18f35fff27571fc1fcb7a4bc8e032 /src/qml/jsruntime/qv4runtime_p.h | |
parent | cb182b46cdbf2fa166bd584afefb07fa90c2b6df (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.h | 9 |
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(); |