Joel VanderWerf wrote:
> Brian Candler wrote:
>> I just had a thought.
>>
>> One of the problems with using strings as hash keys is that every time 
>> you
>> refer to them, you create a throw-away garbage string:
>>
>>     params["id"]
>>             ^
>>             +-- temporary string, needs to be garbage collected
> 
> Setting aside the question of freezing, why can't ruby share string data 
> for all strings generated from the same symbol? And in that case you 
> could do the following to avoid garbage:
> 
>      params[:id.to_s]

Sorry... _reduce_ garbage, not avoid it altogether, since there is still 
the T_STRING, even though the data is reused. It would help more for 
long strings than for short strings, because the T_DATA is smaller in 
proportion.

The idea of a literal for a unique frozen string would reduce garbage 
further, sharing the T_STRING as well as the data.

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407