diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-06-22 11:16:11 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-06-22 09:53:25 +0000 |
commit | 9cc9101f0416ebc352d157534b7c2ce009a44705 (patch) | |
tree | 2cbf7404bc3c25058eb91aa187ac3827d73459ef /src/qml/jsruntime/qv4value_p.h | |
parent | 4ac85039a2e3cd092ad51ae726e01d1eef46e37a (diff) |
Encode numeric literals as int when possible
Change-Id: I5ecc406f06a193b470eb9ac376da6b9f752d01cb
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4value_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 50cecb6598..0e7fc844fa 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -51,6 +51,7 @@ // #include <limits.h> +#include <cmath> #include <QtCore/QString> #include "qv4global_p.h" @@ -687,6 +688,13 @@ struct Encode { val = Value::fromHeapObject(o).asReturnedValue(); } + static ReturnedValue smallestNumber(double d) { + if (static_cast<int>(d) == d && !(d == 0. && std::signbit(d))) + return Encode(static_cast<int>(d)); + else + return Encode(d); + } + operator ReturnedValue() const { return val; } |