This project is archived and is in readonly mode.

#297 ✓resolved
Cheah Chu Yeow

Faster Hash#slice (esp. when key count increases)

Reported by Cheah Chu Yeow | June 2nd, 2008 @ 09:46 AM

See title.

I claim no credit for this patch: credit goes to Grant Hollingworth (see Just want to get it into Rails since it's trivial. I didn't replicate the Hash#except patch (until someone or I am able to profile memory usage).

Benchmark I used included. These are my results:

                     user     system      total        real
small hash#slice_current  1.210000   0.000000   1.210000 (  1.216810)
small hash#slice_patched  0.870000   0.000000   0.870000 (  0.871604)
                     user     system      total        real
big hash#slice_current  0.720000   0.000000   0.720000 (  0.717137)
big hash#slice_patched  0.020000   0.000000   0.020000 (  0.024483)

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket