diff options
Diffstat (limited to 'src/qml/jsruntime/qv4string_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4string_p.h | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index 0a316d85b5..a1763522b5 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -160,6 +160,12 @@ struct Q_QML_PRIVATE_EXPORT StringOrSymbol : public Managed { enum { IsStringOrSymbol = true }; + + inline void makeIdentifier() const; + Identifier identifier() const { return d()->identifier; } + + uint asArrayIndex() const; + #endif }; @@ -204,12 +210,6 @@ struct Q_QML_PRIVATE_EXPORT String : public StringOrSymbol { } uint toUInt(bool *ok) const; - void makeIdentifier() const { - if (d()->identifier.isValid()) - return; - makeIdentifierImpl(); - } - // slow path Q_NEVER_INLINE void makeIdentifierImpl() const; @@ -227,8 +227,6 @@ struct Q_QML_PRIVATE_EXPORT String : public StringOrSymbol { bool startsWithUpper() const { return d()->startsWithUpper(); } - Identifier identifier() const { return d()->identifier; } - protected: static bool isEqualTo(Managed *that, Managed *o); static uint getLength(const Managed *m); @@ -297,6 +295,21 @@ struct ComplexString : String { } }; +inline +void StringOrSymbol::makeIdentifier() 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; +} + template<> inline const StringOrSymbol *Value::as() const { return isManaged() && m()->internalClass->vtable->isStringOrSymbol ? static_cast<const String *>(this) : nullptr; |