Make HashMap::put overwrite (r=jorendorff)
authorLuke Wagner <lw@mozilla.com>
Wed, 17 Feb 2010 10:47:26 -0800
changeset 38591 4593e2fa380e43e391e23fe537cab7270fe07387
parent 38590 15df4512f52f3c195174c127ae1b010dfc1bd8af
child 38592 5a50a2d0fc0fd4b4a12b9281a9189b4f9618c07b
push idunknown
push userunknown
push dateunknown
reviewersjorendorff
milestone1.9.3a2pre
Make HashMap::put overwrite (r=jorendorff)
js/src/jshashtable.h
--- a/js/src/jshashtable.h
+++ b/js/src/jshashtable.h
@@ -801,17 +801,21 @@ class HashMap
     /* Shorthand operations: */
 
     bool has(const Lookup &l) const {
         return impl.lookup(l) != NULL;
     }
 
     Entry *put(const Key &k, const Value &v) {
         AddPtr p = lookupForAdd(k);
-        return p ? &*p : (add(p, k, v) ? &*p : NULL);
+        if (p) {
+            p->value = v;
+            return &*p;
+        }
+        return add(p, k, v) ? &*p : NULL;
     }
 
     void remove(const Lookup &l) {
         if (Ptr p = lookup(l))
             remove(p);
     }
 };