Fix RegExpCache to store Heap Objects
authorLars Knoll <lars.knoll@digia.com>
Mon, 1 Dec 2014 13:29:21 +0000 (14:29 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Sat, 20 Dec 2014 06:39:40 +0000 (07:39 +0100)
Change-Id: I1613c438f5b862436790f81c6a3d370cfe78b6a1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/jsruntime/qv4regexp.cpp
src/qml/jsruntime/qv4regexp_p.h

index 349a0b2..2f1ede1 100644 (file)
@@ -42,7 +42,7 @@ RegExpCache::~RegExpCache()
 {
     for (RegExpCache::Iterator it = begin(), e = end();
          it != e; ++it)
-        it.value()->d()->cache = 0;
+        it.value()->cache = 0;
     clear();
 }
 
@@ -69,8 +69,8 @@ Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bo
 
     RegExpCache *cache = engine->regExpCache;
     if (cache) {
-        if (RegExp *result = cache->value(key))
-            return result->d();
+        if (Heap::RegExp *result = cache->value(key))
+            return result;
     }
 
     Scope scope(engine);
@@ -80,7 +80,7 @@ Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bo
         cache = engine->regExpCache = new RegExpCache;
 
     result->d()->cache = cache;
-    cache->insert(key, result);
+    cache->insert(key, result->d());
 
     return result->d();
 }
index 3219d56..b76c1ac 100644 (file)
@@ -133,7 +133,8 @@ inline RegExpCacheKey::RegExpCacheKey(const RegExp::Data *re)
 inline uint qHash(const RegExpCacheKey& key, uint seed = 0) Q_DECL_NOTHROW
 { return qHash(key.pattern, seed); }
 
-class RegExpCache : public QHash<RegExpCacheKey, RegExp*>
+// ### GC
+class RegExpCache : public QHash<RegExpCacheKey, Heap::RegExp*>
 {
 public:
     ~RegExpCache();