Fix property deletion.
authorErik Verbruggen <erik.verbruggen@digia.com>
Mon, 12 Nov 2012 15:19:04 +0000 (16:19 +0100)
committerLars Knoll <lars.knoll@digia.com>
Mon, 12 Nov 2012 22:16:50 +0000 (23:16 +0100)
Also tweak the bucket size calculation to be prime for just a bit
longer than.

Change-Id: I9fc6779956693301eb01a6558d4c20d8e39d8bad
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
qmljs_objects.h

index 139ea10..857b12b 100644 (file)
@@ -260,11 +260,11 @@ public:
 
     void remove(PropertyTableEntry *prop)
     {
-        PropertyTableEntry *bucket = _buckets[prop->hashValue() % _bucketCount];
-        if (bucket == prop) {
-            bucket = bucket->next;
+        PropertyTableEntry **bucket = _buckets + (prop->hashValue() % _bucketCount);
+        if (*bucket == prop) {
+            *bucket = prop->next;
         } else {
-            for (PropertyTableEntry *it = bucket; it; it = it->next) {
+            for (PropertyTableEntry *it = *bucket; it; it = it->next) {
                 if (it->next == prop) {
                     it->next = it->next->next;
                     break;
@@ -344,7 +344,7 @@ private:
     void rehash()
     {
         if (_bucketCount)
-            _bucketCount *= 2; // ### next prime
+            _bucketCount = _bucketCount * 2 + 1; // ### next prime
         else
             _bucketCount = 11;