On Nov 13, 10:31 am, "Enrico Thierbach"
<[EMAIL PROTECTED]> wrote:

> def to_proc
>   Proc.new { |*args| args.shift.__send__(self, *args) }
> end
>
> with the improved(?) one:
>
> def to_proc
>   @to_proc ||= Proc.new { |*args| args.shift.__send__(self, *args) }
> end

This is interesting.
I can't remember quite what it is that makes .map(&:name) slower
than .map{|o| o.name}

But I have a feeling that it was to do with the cost of instantiating
a new Proc object each time.

With your solution,
I'd be interested in seeing some benchmarks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to