Different cases here possibly call for different approaches. In the case (like in events), where we're in charge of setting up the keys, why not keep a separate Array around with a list of the keys. I'm talking, for instance, about line 306 and 307 in core.js.
In certain other cases (like setting attributes via Objects), doing the typical performance-intensive checks might not be such a big deal. Basically what I'm saying is: let's not completely ignore the possibility of using a more expensive version of the loop in startup cases; focus on keeping the critical path fast (events, selector, etc.) -- Yehuda On Fri, Oct 3, 2008 at 10:47 AM, Ariel Flesler <[EMAIL PROTECTED]> wrote: > console.log("raw time", +new Date - start); > > +new Date --> Yeah! > > >> >> start = +new Date; >> for (var i = 0; i < 1000; i++) { >> var tainted = Object.tainted(); >> for (var key in test) { >> if (!tainted || !Object.prototype[key]) { >> fn(key, test[key]); >> } >> } >> } >> console.log("checked time", +new Date - start); >> >> The second version seems be about 15 to 20 % slower, but thats for a >> million iterations... There difference is much smaller for this >> version: >> > > 20% seems like a relevant percent to me. This is most called method. > Note that having firebug on, messes up numbers. Specially for function > calls (Object.tainted). > I'd try that w/o firebug. > > As a small improvement: > > var clean = !Object.tainted(); > > Saves you one boolean cast for each iteration. > > >> I've modified $.each to include the Object.prototype check and ran it >> against ?core&selector, couldn't see any performance difference, if >> anything, it seemed to be faster. Not a good benchmark either, but >> from what I see, just doing the Object.prototype check, maybe caching >> the Object.prototype lookup in a local var, is safe and irrelevant for >> performance. >> > > Did you tried that (caching in a var) with a benchmarker ? > > -- > Ariel Flesler > http://flesler.blogspot.com > > > > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---