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. 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]; https://en.cppreference.com/w/cpp/container/unordered_set/insert https://codereview.appspot.com/583390043/