diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-11-24 13:30:37 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-11-29 20:15:11 +0000 |
commit | 005857c492ff2a907987e5aed4c61163a6f3fc44 (patch) | |
tree | 3c7a38c250c6c96d26421d26ed8f089a09b92c1d /src/qml/jsruntime/qv4value.cpp | |
parent | 17c7cb2b0dc7f14603932e059013aa8bb39eef27 (diff) |
V4: Streamline Value::toBoolean and prevent calls to Value::type()
Value::type() is not inlined by GCC LTO, and does more work than needed.
Change-Id: I0a1f99f48d8e55caf685a9a3aa56dce079c8f1b2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4value.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4value.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index a3cd212d3b..e34ac9c764 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -77,14 +77,13 @@ int Value::toUInt16() const bool Value::toBoolean() const { - switch (type()) { - case Value::Undefined_Type: - case Value::Null_Type: + if (isInteger() || isBoolean()) + return static_cast<bool>(int_32()); + + if (isUndefined() || isNull()) return false; - case Value::Boolean_Type: - case Value::Integer_Type: - return (bool)int_32(); - case Value::Managed_Type: + + if (isManaged()) { #ifdef V4_BOOTSTRAP Q_UNIMPLEMENTED(); #else @@ -92,9 +91,10 @@ bool Value::toBoolean() const return s->toQString().length() > 0; #endif return true; - default: // double - return doubleValue() && !std::isnan(doubleValue()); } + + // double + return doubleValue() && !std::isnan(doubleValue()); } double Value::toInteger() const |