From: Brian Mitchell Date: 2004-11-01T16:54:35+09:00 Subject: Re: Correction and another Tip. Re: Nuby Tip for the Day : Memoization On Mon, 1 Nov 2004 14:01:34 +0900, John Carter wrote: > On Mon, 1 Nov 2004, Joel VanderWerf wrote: > > > Just a little correction to a worthy post... > > thanks > > > John Carter wrote: > > ... > >> class BigExpensiveMadeOften > >> def initialize( unique_name) > >> # Big expensive computation > >> end > >> > > make that > @@memo = Hash.new {|hash,key| hash[key] = BigExpensiveMadeOften.new( key)} > > Reminder for the day for not so Nubies... > > Every reference to a string is a String.new, so sometimes factoring out string constants out of inner loops can be a big win... > Possibly you meant a string literal. A reference is what the variable ends up holding. Brian Mitchell