[ruby-core:77291] Re: RFC: optimizations opportunities in Hash#merge!
From:
Martin J. Dürst <duerst@...>
Date:
2016-09-16 10:21:01 UTC
List:
ruby-core #77291
On 2016/09/14 01:57, Sylvain Joyeux wrote: > I'm using Hash#merge and other hash-related update methods extensively, to > the point where I spend a significant amount of time in #hash. > > So I went digging. It appears that Hash#merge is actually re-hashing its > keys twice (once to compare the two hashes, and once to re-assign to the > receiver). > > However, under the assumption that the block in Hash#merge! is not allowed > to modify the key, no hashing should be needed at all. > > Or am I missing something ? Based on the documentation, it doesn't look like changing the key is intended at all. But what about doing some code search to find examples of Hash#merge and friends and checking whether there are some key updates or not? > I am ready to work on this, but I want to have a feel for whether such work > would be welcome by the code devs before I invest time in it ... rather > than have it thrown away as WONTFIX later. I can't speak for others, but speed improvements should certainly be welcome. You may want to open a feature request on bugs.ruby-lang.org to submit your patch (or even before). Regards, Martin. Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>