On 05/02/2008, Rauan Maemirov
<rauan1987-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> I have some doubts on $ performance. Is it better to use multiple $(),
> than e.g. elem = $(''elem'') and then using elem or elem
would be just a
> link for $(''elem'')?
From general programming sense, if you have to keep calling a method
on an object, it will be slower than keeping a copy of the result of
the first call.
But this has to be balanced with readability and suitability.
If you only have 1 or 2 (or maybe 3) calls to elem, then MAYBE you get
away without it.
If that is in a loop of hundreds, then maybe not.
If you can chain the use ...
$(''elem'').method1().method2().method3();
then that is only 1 call.
--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---