diff --git a/js/public/HashTable.h b/js/public/HashTable.h index f60014766c3b..918093c7e53c 100644 --- a/js/public/HashTable.h +++ b/js/public/HashTable.h @@ -295,8 +295,13 @@ class HashTable : private AllocPolicy uint64 mutationCount; #endif - static const unsigned sMinSizeLog2 = 4; + /* The default initial capacity is 16, but you can ask for as small as 4. */ + static const unsigned sMinSizeLog2 = 2; static const unsigned sMinSize = 1 << sMinSizeLog2; + static const unsigned sDefaultInitSizeLog2 = 4; + public: + static const unsigned sDefaultInitSize = 1 << sDefaultInitSizeLog2; + private: static const unsigned sMaxInit = JS_BIT(23); static const unsigned sMaxCapacity = JS_BIT(24); static const unsigned sHashBits = tl::BitSize::result; @@ -986,7 +991,7 @@ class HashMap * init after constructing a HashMap and check the return value. */ HashMap(AllocPolicy a = AllocPolicy()) : impl(a) {} - bool init(uint32 len = 0) { return impl.init(len); } + bool init(uint32 len = Impl::sDefaultInitSize) { return impl.init(len); } bool initialized() const { return impl.initialized(); } /* @@ -1214,7 +1219,7 @@ class HashSet * init after constructing a HashSet and check the return value. */ HashSet(AllocPolicy a = AllocPolicy()) : impl(a) {} - bool init(uint32 len = 0) { return impl.init(len); } + bool init(uint32 len = Impl::sDefaultInitSize) { return impl.init(len); } bool initialized() const { return impl.initialized(); } /*