https://bugzilla.wikimedia.org/show_bug.cgi?id=15402
[email protected] changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #17 from [email protected] 2008-12-27 14:01:27 UTC --- (In reply to comment #14) > I'm quite sure that initializing an > extra local variable is much more expensive than an extra array access. No, a variable declared with |var| at function scope is very cheap. It's similar to a register in any decent ECMAScript implementation. Using as much local variables as possible (if used more than once) is the most important optimization (except better algorithms). An array access in ECMAScript usually needs conversion of the index to a string and a hash table lookup. An ECMAScript array is just an object with a special prototype and a magic |length| property. If the array or object is a host object (like in |table.rows[i].cells|), accesses may also need security checks, which are the most expensive thing. BTW, an additional optimization would be to store |document| in a local variable if used more than once. It's almost guaranteed to need a security check at every access as a global property. And |this| is faster than |window| where they are equivalent (|window|, like |self|, is a self-reference). -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. You are on the CC list for the bug. _______________________________________________ Wikibugs-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
