Jean-Philippe Encausse
2007-Feb-12 13:30 UTC
Benchmark Question: Element.getElementsBySelector()
Hi ! I saw in documentation that getElementsBySelector() can work on multiple selectors separated by coma. Is this method is Smart ? * getElementsBySelector(''A'',''P.cazz'', ''C[attrib]''); Is faster that: * getElementsBySelector(''A''); * getElementsBySelector(''P.cazz''); * getElementsBySelector(''C[attrib]''); For is it only a loop on given parameters with multiple parsing ? Best Regards, Jp -- Jean-Philippe Encausse - R&D Jalios SA Jp [at] encausse.net - http://www.encausse.com - http://www.jalias.com GTalk: jp.encausse [at] gmail.com - SMS: sms [at] jp.encausse.net Mob: +33 6 82 12 56 99 Jalios: +33 1 39 23 92 83 Tel: +33 1 39 18 90 15 Do it Once, Use it Twice ~ Do it Twice, Make It Once --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2007-Feb-12 14:16 UTC
Re: Benchmark Question: Element.getElementsBySelector()
Hey Jean-Philippe, Casual perusal of the source code tells you that gEBS just forwards its argument list (minus the initial element) to Selector.findChildElements, available around line 1858, and this function essentially maps over the expressions. So going with one call is going to be slightly faster, but on a very small scale: you just save the cost of a few extra function calls to gEBS, Selector.findChildElements, and map (with its lexical closure cost here). In short, it''s not going to be noticably faster or slower one way or another. On the other hand, it IS going to be more concise if you use only one call, as in your first example. -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---