Hi,

In a recent thread 
(http://mozdev.org/pipermail/project_owners/2006-April/007711.html), Konstantin
hinted that use of a temp variable is better optimized than repeated reference 
to a deeply nested
property. I'm wondering if anyone can comment on this? I'm more used to 
compiled languages where
this kind of thing is irrelevent. Is it relevent in Mozilla (SpiderMonkey) 
Javascript?

Example: which is more efficient, or are they the same?

var o = {};
o.o = {}, o.o.o = {}, o.o.o.o = {}, o.o.o.o.o = "foo";
for (var i=0; i<999999; i++)
  dump(o.o.o.o.o);

or

var o = {};
o.o = {}, o.o.o = {}, o.o.o.o = {}, o.o.o.o.o = "foo";
var tmp = o.o.o.o.o;
for (var i=0; i<999999; i++)
  dump(temp);

If there's a way to benchmark this (Venkmann?), I'd like to know.

Thanks for the advice,
Eric
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners

Reply via email to