|
4 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this
|
5 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
6 | 6 |
|
| 7 | +// A note on the differences between mozilla::HashTable and PLDHashTable (and |
| 8 | +// its subclasses, such as nsTHashtable). |
| 9 | +// |
| 10 | +// - mozilla::HashTable is a lot faster, largely because it uses templates |
| 11 | +// throughout *and* inlines everything. PLDHashTable inlines operations much |
| 12 | +// less aggressively, and also uses "virtual ops" for operations like hashing |
| 13 | +// and matching entries that require function calls. |
| 14 | +// |
| 15 | +// - Correspondingly, mozilla::HashTable use is likely to increase executable |
| 16 | +// size much more than PLDHashTable. |
| 17 | +// |
| 18 | +// - mozilla::HashTable has a nicer API, with a proper HashSet vs. HashMap |
| 19 | +// distinction. |
| 20 | +// |
| 21 | +// - mozilla::HashTable requires more explicit OOM checking. Use |
| 22 | +// mozilla::InfallibleAllocPolicy to make allocations infallible; note that |
| 23 | +// return values of possibly-allocating methods such as add() will still need |
| 24 | +// checking in some fashion -- e.g. with MOZ_ALWAYS_TRUE() -- due to the use |
| 25 | +// of MOZ_MUST_USE. |
| 26 | +// |
| 27 | +// - mozilla::HashTable has a default capacity on creation of 32 and a minimum |
| 28 | +// capacity of 4. PLDHashTable has a default capacity on creation of 8 and a |
| 29 | +// minimum capacity of 8. |
| 30 | +// |
| 31 | +// - mozilla::HashTable allocates memory eagerly. PLDHashTable delays |
| 32 | +// allocating until the first element is inserted. |
| 33 | + |
7 | 34 | #ifndef mozilla_HashTable_h
|
8 | 35 | #define mozilla_HashTable_h
|
9 | 36 |
|
|
0 commit comments