[Webkit-unassigned] [Bug 103259] Numeric identifiers of events are not guaranteed to be unique

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Nov 27 20:29:07 PST 2012


https://bugs.webkit.org/show_bug.cgi?id=103259





--- Comment #7 from Cosmin Truta <ctruta at gmail.com>  2012-11-27 20:31:20 PST ---
(In reply to comment #6)
> Why does add() return "isNewEntry" if it doesn't overwrite?

Both HashMap::set and HashMap::add return an object of type HashTableType::AddResult, which is an (iterator, isNewEntry) tuple.
The iterator member points to the newly-added or already-existing object (depending on what gets called); the isNewEntry member is true if a new object has just been set or added, and false in case of replacement (for set) or failure (for add).

See the difference in the implementation of HashMap::set and HashMap::add. They both call HashMap::inlineAdd; but the difference is that HashMap::add does nothing on failure, while HashMap::set does the following:

    if (!result.isNewEntry) {
        // The inlineAdd call above found an existing hash table entry; we need to set the mapped value.
        MappedTraits::store(mapped, result.iterator->second);
    }

In my patch, by replacing HashMap::set with HashMap::add, I no longer execute the above code, leaving the original key/value pair intact.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list