diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsapi/qjsvalue_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4mathobject.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 11 |
3 files changed, 10 insertions, 7 deletions
diff --git a/src/qml/jsapi/qjsvalue_p.h b/src/qml/jsapi/qjsvalue_p.h index 62e09f72be..bcf0a9d12d 100644 --- a/src/qml/jsapi/qjsvalue_p.h +++ b/src/qml/jsapi/qjsvalue_p.h @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE -class QJSValuePrivate +class Q_AUTOTEST_EXPORT QJSValuePrivate { public: static inline QV4::Value *getValue(const QJSValue *jsval) diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index 652f6c603e..e176235786 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -399,7 +399,7 @@ ReturnedValue MathObject::method_max(const FunctionObject *, const Value *, cons if (x > mx || std::isnan(x)) mx = x; } - RETURN_RESULT(Encode(mx)); + RETURN_RESULT(Encode::smallestNumber(mx)); } ReturnedValue MathObject::method_min(const FunctionObject *, const Value *, const Value *argv, int argc) @@ -412,7 +412,7 @@ ReturnedValue MathObject::method_min(const FunctionObject *, const Value *, cons mx = x; } } - RETURN_RESULT(Encode(mx)); + RETURN_RESULT(Encode::smallestNumber(mx)); } ReturnedValue MathObject::method_pow(const FunctionObject *, const Value *, const Value *argv, int argc) diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 7c9ca9c0bf..6a6df3eb6d 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -334,14 +334,17 @@ public: return true; if (isDouble()) { double d = doubleValue(); - int i = (int)d; - if (i == d && !(d == 0 && std::signbit(d))) { - setInt_32(i); + if (isInt32(d)) { + setInt_32(int(d)); return true; } } return false; } + QML_NEARLY_ALWAYS_INLINE static bool isInt32(double d) { + int i = int(d); + return (i == d && !(d == 0 && std::signbit(d))); + } double asDouble() const { if (tag() == quint32(ValueTypeInternal::Integer)) return int_32(); @@ -733,7 +736,7 @@ struct Encode { } static ReturnedValue smallestNumber(double d) { - if (static_cast<int>(d) == d && !(d == 0. && std::signbit(d))) + if (Value::isInt32(d)) return Encode(static_cast<int>(d)); else return Encode(d); |