aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-12-10 18:07:26 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-12-18 14:23:29 +0100
commitd2e331dfa02475e773e51af6e7532951f4d1a233 (patch)
treed16f2ef9cfd363ff09d06fed70b226ccb212f3ca /src/qml/jsruntime
parent31211f1415f221ed1a974663fdde117fd6de357d (diff)
Allow JavaScript primitive type transformations inline in C++
We don't want to call into the engine just for adding two numbers. This implements the most common operators on primitive JavaScript values. More are to follow in the future. Change-Id: Id51a5af59a3af9fec78a2d8f293e59e6567e9204 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4typedarray.cpp2
-rw-r--r--src/qml/jsruntime/qv4value_p.h4
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp
index f425c6c87f..c816465d76 100644
--- a/src/qml/jsruntime/qv4typedarray.cpp
+++ b/src/qml/jsruntime/qv4typedarray.cpp
@@ -63,7 +63,7 @@ static inline int toInt32(Value v)
Q_ASSERT(v.isNumber());
if (v.isInteger())
return v.integerValue();
- return Double::toInt32(v.doubleValue());
+ return QJSNumberCoercion::toInteger(v.doubleValue());
}
static inline double toDouble(Value v)
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 530c8eaf27..44383689b4 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -434,9 +434,9 @@ inline int Value::toInt32() const
return int_32();
if (Q_LIKELY(isDouble()))
- return Double::toInt32(doubleValue());
+ return QJSNumberCoercion::toInteger(doubleValue());
- return Double::toInt32(toNumberImpl());
+ return QJSNumberCoercion::toInteger(toNumberImpl());
}
inline unsigned int Value::toUInt32() const
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index 4815f5ad91..9fefa2a38c 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -425,7 +425,7 @@ static bool compareEqualInt(QV4::Value &accumulator, QV4::Value lhs, int rhs)
d = val.toNumberImpl(); \
CHECK_EXCEPTION; \
} \
- i = Double::toInt32(d); \
+ i = QJSNumberCoercion::toInteger(d); \
} \
} while (false)