aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4string_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-23 23:07:23 +0200
committerLars Knoll <lars.knoll@qt.io>2018-07-02 19:29:43 +0000
commit56bff8f7abc2f0eeadd4d197667132af6eed6f3a (patch)
tree13990d34f9239e1845dedaa452bc1093f38b027a /src/qml/jsruntime/qv4string_p.h
parent86f88521fbea59e8ec53e50cc1e3e68a61f53c40 (diff)
Clean up the property key API in StringOrSymbol
Get rid of makeIdentifier(), as toPropertyKey() will take care of it. Rename identifier() to propertyKey() and check that the key is valid. Remove String/StringOrSymbol::asArrayIndex(), we don't need it anymore. Change-Id: I3c490fabc1475c9ea288b49b1638b6fa1bc237b7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4string_p.h')
-rw-r--r--src/qml/jsruntime/qv4string_p.h31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h
index 81cb54d9cc..65efbe31c2 100644
--- a/src/qml/jsruntime/qv4string_p.h
+++ b/src/qml/jsruntime/qv4string_p.h
@@ -173,13 +173,13 @@ struct Q_QML_PRIVATE_EXPORT StringOrSymbol : public Managed {
IsStringOrSymbol = true
};
- inline void makeIdentifier() const;
- PropertyKey identifier() const { return d()->identifier; }
-
- uint asArrayIndex() const;
-
+private:
+ inline void createPropertyKey() const;
+public:
+ PropertyKey propertyKey() const { Q_ASSERT(d()->identifier.isValid()); return d()->identifier; }
PropertyKey toPropertyKey() const;
+
inline QString toQString() const {
return d()->toQString();
}
@@ -217,18 +217,10 @@ struct Q_QML_PRIVATE_EXPORT String : public StringOrSymbol {
inline unsigned hashValue() const {
return d()->hashValue();
}
- uint asArrayIndex() const {
- if (subtype() >= Heap::String::StringType_Unknown)
- d()->createHashValue();
- Q_ASSERT(d()->subtype < Heap::String::StringType_Complex);
- if (subtype() == Heap::String::StringType_ArrayIndex)
- return d()->stringHash;
- return UINT_MAX;
- }
uint toUInt(bool *ok) const;
// slow path
- Q_NEVER_INLINE void makeIdentifierImpl() const;
+ Q_NEVER_INLINE void createPropertyKeyImpl() const;
static uint createHashValue(const QChar *ch, int length, uint *subtype)
{
@@ -313,18 +305,11 @@ struct ComplexString : String {
};
inline
-void StringOrSymbol::makeIdentifier() const {
+void StringOrSymbol::createPropertyKey() const {
if (d()->identifier.isValid())
return;
Q_ASSERT(isString());
- static_cast<const String *>(this)->makeIdentifierImpl();
-}
-
-inline
-uint StringOrSymbol::asArrayIndex() const {
- if (isString())
- return static_cast<const String *>(this)->asArrayIndex();
- return UINT_MAX;
+ static_cast<const String *>(this)->createPropertyKeyImpl();
}
template<>