From 45f7120d42f628e86ae2bf3bd2789fdb190490e0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 8 May 2014 22:27:23 +0200 Subject: Convert regexps Change-Id: I5b62a265a7ce363a16b1e14ae93cadbb1ab0cb5b Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4regexp_p.h | 75 ++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 38 deletions(-) (limited to 'src/qml/jsruntime/qv4regexp_p.h') diff --git a/src/qml/jsruntime/qv4regexp_p.h b/src/qml/jsruntime/qv4regexp_p.h index 983fd03351..29f759f93c 100644 --- a/src/qml/jsruntime/qv4regexp_p.h +++ b/src/qml/jsruntime/qv4regexp_p.h @@ -62,38 +62,13 @@ QT_BEGIN_NAMESPACE namespace QV4 { struct ExecutionEngine; +struct RegExpCacheKey; -struct RegExpCacheKey -{ - RegExpCacheKey(const QString &pattern, bool ignoreCase, bool multiLine) - : pattern(pattern) - , ignoreCase(ignoreCase) - , multiLine(multiLine) - { } - explicit inline RegExpCacheKey(const RegExp *re); - - bool operator==(const RegExpCacheKey &other) const - { return pattern == other.pattern && ignoreCase == other.ignoreCase && multiLine == other.multiLine; } - bool operator!=(const RegExpCacheKey &other) const - { return !operator==(other); } - - QString pattern; - uint ignoreCase : 1; - uint multiLine : 1; -}; - -inline uint qHash(const RegExpCacheKey& key, uint seed = 0) Q_DECL_NOTHROW -{ return qHash(key.pattern, seed); } - -class RegExpCache : public QHash -{ -public: - ~RegExpCache(); -}; - -class RegExp : public Managed +struct RegExp : public Managed { struct Data : Managed::Data { + Data(ExecutionEngine* engine, const QString& pattern, bool ignoreCase, bool multiline); + ~Data(); QString pattern; OwnPtr byteCode; #if ENABLE(YARR_JIT) @@ -129,8 +104,7 @@ class RegExp : public Managed bool ignoreCase() const { return d()->ignoreCase; } bool multiLine() const { return d()->multiLine; } - static RegExp* create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase = false, bool multiline = false); - ~RegExp(); + static RegExp::Data* create(ExecutionEngine* engine, const QString& pattern, bool ignoreCase = false, bool multiline = false); bool isValid() const { return d()->byteCode.get(); } @@ -141,19 +115,44 @@ class RegExp : public Managed static void destroy(Managed *that); static void markObjects(Managed *that, QV4::ExecutionEngine *e); -private: friend class RegExpCache; - Q_DISABLE_COPY(RegExp); - RegExp(ExecutionEngine* engine, const QString& pattern, bool ignoreCase, bool multiline); +}; + +struct RegExpCacheKey +{ + RegExpCacheKey(const QString &pattern, bool ignoreCase, bool multiLine) + : pattern(pattern) + , ignoreCase(ignoreCase) + , multiLine(multiLine) + { } + explicit inline RegExpCacheKey(const RegExp::Data *re); + + bool operator==(const RegExpCacheKey &other) const + { return pattern == other.pattern && ignoreCase == other.ignoreCase && multiLine == other.multiLine; } + bool operator!=(const RegExpCacheKey &other) const + { return !operator==(other); } + QString pattern; + uint ignoreCase : 1; + uint multiLine : 1; }; -inline RegExpCacheKey::RegExpCacheKey(const RegExp *re) - : pattern(re->pattern()) - , ignoreCase(re->ignoreCase()) - , multiLine(re->multiLine()) +inline RegExpCacheKey::RegExpCacheKey(const RegExp::Data *re) + : pattern(re->pattern) + , ignoreCase(re->ignoreCase) + , multiLine(re->multiLine) {} +inline uint qHash(const RegExpCacheKey& key, uint seed = 0) Q_DECL_NOTHROW +{ return qHash(key.pattern, seed); } + +class RegExpCache : public QHash +{ +public: + ~RegExpCache(); +}; + + } -- cgit v1.2.3