By calling reserve with the size we expected for the unordered_multiset container we avoided the multiple rehashes that the increases in container size could have produced and optimized the size of the hash table.