On 8/14/05, Ara.T.Howard <Ara.T.Howard / noaa.gov> wrote:
> On Sun, 14 Aug 2005, Joe Van Dyk wrote:
> 
> >> On Sun, 14 Aug 2005, Joe Van Dyk wrote:
> <snip>
> > Thanks!  I shall study this code (there's a few new idioms that I
> > haven't used before) and report back early next week on the
> > performance improvements.
> 
> try this one - it's another order of magnitude faster:
> 
> 
>      harp:~ > ruby a.rb
>      #<PlayerData:0xb75cc0b4 @to_s=nil, @data=[400, 1.0, 2.0, 3.0, 42], @to_bin=nil>
>      400
>      1.0
>      42
>      pid : 400, x_position : 1.0, y_position : 2.0, z_position : 3.0, foobar : 42
>      creations per second : 114797
> 
> 
>      harp:~ > cat a.rb
>      class PlayerData
>        class << self
>          def create(*a)
>            new(a.pack(FORMAT))
>          end
>        end


Why do you use 'class << self' here?

Thanks,
Joe