On 2020/01/24 15:50:22, Dan Eble wrote: > On 2020/01/24 15:17:02, dak wrote: > > On 2020/01/24 14:11:59, Dan Eble wrote: > > > On 2020/01/24 14:06:22, hanwenn wrote: > > > > If the allocation cost becomes problematic, we can use another hashmap > > > instead. > > > > > > "We" could profile it and know before pushing whether it is worth it. > > > > I don't think that this is really performance-critical. > > I accept your informed intuition, but I also have more suggestions. > > Don't assume the hash function is perfect: create the table with more buckets, > say 2*size.
I'd not do that. It's second-guessing the implementation. The size should be good as a hint. In particular if there are actual duplicates... > Instead of calling find() then insert(), just call insert() and check whether it > worked, something like this (untested): > > if (seen.insert(grobs[i]).second) > grobs[j++] = grobs[i]; Ok, that's a good idea. > https://en.cppreference.com/w/cpp/container/unordered_set/insert https://codereview.appspot.com/583390043/