On May 25, 3:10 am, "Mislav Marohnić" <[EMAIL PROTECTED]>
wrote:
> It calls Element.hasClassName for every node, I hope we can agree on that.
> Now, let us remember what do methods from the Element namespace all have in
> common.
>
> Hint: it has something to do with the first argument and the $ function.

Wow. That's a show-stopper. We need to fix this immediately.
(Apologies, Mislav.)

I worked on getElementsByClassName optimization about six months ago.
Sometime after that, it was changed to use Element.hasClassName --
presumably to stay DRY, but at a huge performance cost. I haven't
noticed this because I've given up getElementsByClassName almost
entirely -- in favor of $$ and getElementsBySelector.

Everyone on Core needs to understand: in IE, the cost of calling $ is
trivial in a single case, but in a loop it can be the difference
between instantaneous loading and a thirty-second freeze. That's why I
had to write new versions of all these functions for selector.js: I
needed functions that did not call $ or Element.extend, so that I
could be sure that no elements were extended until the final result
set.

Prototype isn't an optimize-first library, but every function that
queries the DOM needs every millisecond squeezed out of it. Since
there is no limit to the number of nodes on a page, there is no DOM
querying scenario that will not become a performance issue when taken
to its logical edge case (one needle, gigantic haystack). So we need
to be extra sensitive about this. Perhaps we should set some minimum
performance standards and run a couple benchmarks automatically as
part of the unit tests.

Once again to the original author: in light of this new information, $
$ should be faster than getElementsByClassName. This is both true and
ridiculous.

Cheers,
Andrew


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" 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/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to