[Laszlo-dev] For Review: Change 20081021-Philip-6. Summary: Iterate over arrays with for "for (var a=0; a<b.length; a++)"

André Bargull andre.bargull at udo.edu
Tue Oct 21 12:04:02 PDT 2008


IMO it's bad to use l because of 1, I'd suggest to use "len" instead.

LzProfile.lzs still needs to be fixed (it iterates over its buffers with 
a for-in loop). There was something special about the profiler, you've 
explained it to me once, but I don't know whether it's still valid in 
respect to your recent changes.

> May I suggest that for efficiency (because most compiler's can't tell  
> if the length of an array might be changed by an iteration) that we  
> use the idiom:
>
>    for (var i = 0, l = b.length; i < l; i++)
>
> ?  (I.e., cache the length of the array for the while test.)
>
> Otherwise, approved.
>
> On 2008-10-21, at 14:36EDT, Philip Romanik wrote:
>
> >/ Change 20081021-Philip-6 by Philip at Philip-DC <http://www.openlaszlo.org/mailman/listinfo/laszlo-dev> on 2008-10-21 08:49:47  
> />/ EDT
> />/    in /cygdrive/f/laszlo/svn/src/svn/openlaszlo/trunk
> />/    for http://svn.openlaszlo.org/openlaszlo/trunk
> />/
> />/ Summary: Iterate over arrays with for "for (var a=0; a<b.length; a++)"
> />/
> />/ New Features:
> />/
> />/ Bugs Fixed: LPP-7048, LPP-4435
> />/
> />/ Technical Reviewer: ptw
> />/ QA Reviewer: (pending)
> />/ Doc Reviewer: (pending)
> />/
> />/ Documentation:
> />/
> />/ Release Notes:
> />/
> />/ Details:
> />/ To prevent issues with applications who extend Array (like  
> />/ Prototype), the use of "for(a in b)" is replaced with "for (var a=0;  
> />/ a<b.length; a++)".
> />/
> />/
> />/ Tests:
> />/ I made sure that the affected files work properly by exercising  
> />/ their related tests in swf/dhtml:
> />/
> />/ http://localhost:8080/trunk/lps/components/incubator/test/opttree/test.lzx
> />/ http://localhost:8080/trunk/test/lztest/lztest-animator.lzx
> />/ http://localhost:8080/trunk/test/rpc/javarpc/simple.lzx
> />/ http://localhost:8080/trunk/test/rpc/xmlrpc/advogato.lzx
> />/ http://localhost:8080/trunk/lps/components/utils/diagnostic/inspector/inspector-example.lzx
> />/ http://localhost:8080/trunk/test/explicit-replicators/lazy-replicator.lzx
> />/ http://localhost:8080/trunk/test/explicit-replicators/test-replicator.lzx
> />/ http://localhost:8080/trunk/test/history/history.lzx
> />/
> />/
> />/ Files:
> />/ M      lps/components/rpc/rpc.lzx
> />/ M      lps/components/rpc/xmlrpc.lzx
> />/ M      lps/components/lztest/lztestmanager.lzx
> />/ M      lps/components/incubator/opttree/opttree.lzx
> />/ M      lps/components/utils/diagnostic/inspector/inspector.lzx
> />/ M      lps/components/utils/replicator/lazyreplicator.lzx
> />/ M      lps/components/utils/replicator/replicator.lzx
> />/ M      lps/includes/source/lzhistory.js
> />/
> />/ Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20081021-Philip-6.tar
> />/
> /
>   



More information about the Laszlo-dev mailing list