diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-20 15:19:17 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-31 07:28:28 +0000 |
commit | fcf9b7efa5b2a0d8f49e59b2a977b8122632aff6 (patch) | |
tree | 18f37a5a7775c5876947236fc6913a3a3e227f36 /src/qml/compiler/qv4compileddata_p.h | |
parent | 8e45393d10ca649c46a82eb8c125bd38cc5b5615 (diff) |
Clean up constant storage for CompiledData::Binding
Store doubles in bindings in the constant table of the compilation unit
instead of each binding. This removes one of the two 8 byte members of
the value union and also allows for sharing of constants throughout a
.qml file.
Change-Id: I1d7daafdb7f24e34c14cd160d2dcb2c5aaac1c50
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compileddata_p.h')
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 31e83e8f76..7bbc4d2835 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -404,7 +404,7 @@ struct Q_QML_PRIVATE_EXPORT Binding }; union { bool b; - quint64 doubleValue; // do not access directly, needs endian protected access + quint32_le constantValueIndex; quint32_le compiledScriptIndex; // used when Type_Script quint32_le objectIndex; TranslationData translationData; // used when Type_Translation @@ -470,22 +470,15 @@ struct Q_QML_PRIVATE_EXPORT Binding bool isTranslationBinding() const { return type == Type_Translation || type == Type_TranslationById; } bool evaluatesToString() const { return type == Type_String || isTranslationBinding(); } - QString valueAsString(const Unit *unit) const; - QString valueAsScriptString(const Unit *unit) const; - double valueAsNumber() const +#ifndef V4_BOOTSTRAP + QString valueAsString(const CompilationUnit *unit) const; + QString valueAsScriptString(const CompilationUnit *unit) const; +#endif + double valueAsNumber(const Value *constantTable) const { if (type != Type_Number) return 0.0; - quint64 intval = qFromLittleEndian<quint64>(value.doubleValue); - double d; - memcpy(&d, &intval, sizeof(double)); - return d; - } - void setNumberValueInternal(double d) - { - quint64 intval; - memcpy(&intval, &d, sizeof(double)); - value.doubleValue = qToLittleEndian<quint64>(intval); + return constantTable[value.constantValueIndex].doubleValue(); } bool valueAsBoolean() const |