lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simplify and speed up uniquify (issue 583390043 by address@hidden)


From: nine . fierce . ballads
Subject: Re: Simplify and speed up uniquify (issue 583390043 by address@hidden)
Date: Fri, 24 Jan 2020 07:50:21 -0800

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/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]