RE: AS 2.0 optimising.. 2004-03-16 - By ryanm
Back > In the last example the lookup of a word is very fast, because u dont need > to loop. > > What im trying to say is that the difference in speed depends on the usage. > Right, but in an individual lookup, using a numeric index is faster and uses less memory than a string. If you *have* to loop through a bunch of items, then an array will be faster. If you can avoid the loop by going directly to the object you need by name, then an array obviously isn't a good choice. That choice is easy, the place where this becomes important is in the difference between these:
for(var i=0;i<limit;i++){ doSomething(object["sub"+i]); }
or
for(var i=0;i<limit;i++){ doSomething(object[i]); }
The second should execute faster, the amount varying directly with the size of the integer "limit".
ryanm
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Supported by Fig Leaf Software =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Be sure to check the archives and the wiki: http://chattyfig.figleaf.com/ =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:107070 =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe send a blank e-mail to: Normal Mode: flashcoders-unsubscribe@(protected) Digest Mode: flashcoders-digest-unsubscrive@(protected)
|
|