Hi,

PLDHashTable, nsTHashtable, and all their subclasses require a
*capacity* to be specified when they are created. If the given
capacity is not a power-of-two, it is rounded up to the next highest
power-of-two. A table with a given capacity can hold at most
0.75*capacity elements, and the average table will hold 0.5*capacity
elements.

However, it's clear that lots of people thought that the initial value
given upon creation was a *length* rather than a *capacity*, i.e.
indicates how many elements the table will contain. For example, there
were dozens of places where a hash table was created and initialized
by inserting elements from a fixed-length list with length N, but the
specified capacity was also N, which means the table will have to be
resized (and rehashed) along the way.

Therefore, in bug 1050009 I changed things so that the given value is
a length rather than a capacity. This means these types are now
consistent with js::HashTable. I audited every place a hash table was
created and adjusted the parameter appropriately.

Finally, for PLDHashTable, the length parameter is now an optional
parameter. (It was already optional for nsTHashtable and its
subclasses.)

Nick
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to