diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-05-08 22:27:23 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-07-22 13:49:17 +0200 |
commit | 45f7120d42f628e86ae2bf3bd2789fdb190490e0 (patch) | |
tree | 5a90ec2c80f46d20124cf4adac14704777301f46 /src/qml/jsruntime/qv4regexp_p.h | |
parent | 4632c0bfff911fa84f00aab9721519427cfa9921 (diff) |
Convert regexps
Change-Id: I5b62a265a7ce363a16b1e14ae93cadbb1ab0cb5b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4regexp_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4regexp_p.h | 75 |
1 files changed, 37 insertions, 38 deletions
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<RegExpCacheKey, RegExp*> -{ -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<JSC::Yarr::BytecodePattern> 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<RegExpCacheKey, RegExp::Data *> +{ +public: + ~RegExpCache(); +}; + + } |