Allow HashMaps with non-default-constructible keys

NEW
Unassigned

Status

()

Core
JavaScript Engine
6 years ago
4 years ago

People

(Reporter: jorendorff, Unassigned)

Tracking

Other Branch
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

6 years ago
Currently js::HashMap<K, V, ...> requires K and V to be default-constructible, but I think this is only because js::detail::HashTableEntry contains these methods:

    void setFree()                { keyHash = sFreeKey; t = T(); }
    void setRemoved()             { keyHash = sRemovedKey; t = T(); }

HashTableEntry would have to be rewritten to call t's destructor
when changing state from live to free or removed.

As a prerequisite, we would need to JS_ASSERT(found()) in these methods of HashTable::Ptr:

        T &operator*() const                  { return entry->t; }
        T *operator->() const                 { return &entry->t; }
(Assignee)

Updated

4 years ago
Assignee: general → nobody
You need to log in before you can comment on or make changes to this bug.