From: khaines@... Date: 2007-09-07T00:27:00+09:00 Subject: Re: Symbols and frozen strings On Thu, 6 Sep 2007, 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 Absolutely. Whether you need to care about this, though, depends on how often your code is building these throwaway strings, and on just how much you really need to neurotically performance tweak your code. What I do to deal with this in code where I consider it important is to use constants that contain frozen strings. Id = 'id'.freeze params[Id] Constant lookup isn't the fastest thing in Ruby, but it's faster than the combined load of creating the throwaway string object, and then garbage collecting it. Kirk Haines