From: Jeremy Kemper Date: 2009-11-10T15:44:15+09:00 Subject: [ruby-core:26659] Re: HashWithIndifferentAccess to core On Sun, Nov 8, 2009 at 7:06 AM, Nobuyoshi Nakada wrote: > Hi, > > At Sun, 8 Nov 2009 12:25:54 +0900, > Yusuke ENDOH wrote in [ruby-core:26612]: >> > I've been toying with allowing custom hashing from the Ruby side for the >> > past 2 days and have a semi-functional version (patch attached against >> > subversion trunk 25671 - http://gist.github.com/228773) >> >> Unfortunately, your patch has a serious problem; it lets RHash have >> four VALUEs, which makes any object require 24 bytes (traditionally >> 20 bytes) in 32 bit envirionment. > > I don't think that index_with object is necessary, why the hash > itself can't have such methods? I really like this customized behavior. It can be used more generically, for example to optimize Rack's very slow HeaderHash. It's slower than Lourens' original patch, though: user system total real naude #[:abc] 0.050000 0.000000 0.050000 ( 0.052469) nobu #[:abc] 0.140000 0.000000 0.140000 ( 0.144207) rails #[:abc] 0.280000 0.000000 0.280000 ( 0.287421) naude #["ab"] 0.080000 0.000000 0.080000 ( 0.080840) nobu #["ab"] 0.140000 0.000000 0.140000 ( 0.135914) rails #["ab"] 0.070000 0.000000 0.070000 ( 0.078379) Benchmark at http://github.com/jeremy/rails/blob/hwia/activesupport/hwia.rb jeremy