[Laszlo-checkins] r10666 - in openlaszlo/trunk/WEB-INF/lps/lfc: data debugger kernel/swf services

bargull@openlaszlo.org bargull at openlaszlo.org
Tue Aug 12 13:21:21 PDT 2008


Author: bargull
Date: 2008-08-12 13:21:13 -0700 (Tue, 12 Aug 2008)
New Revision: 10666

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzParam.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzDebug.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzFontManager.as
   openlaszlo/trunk/WEB-INF/lps/lfc/services/LzFocus.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/services/LzTrack.lzs
Log:
Change 20080812-bargull-R01 by bargull at dell--p4--2-53 on 2008-08-12 12:09:05
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: replace for-in loops over Arrays

New Features:

Bugs Fixed: LPP-4435 (only lfc-part) 

Technical Reviewer: promanik
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
Replaced for-in loops over Arrays with a normal for-loop. 
This change is essential if you use Array extensions (e.g. from Prototype), or you'll end up iterating over the added properties. 
Open issue: The Profiler uses Arrays instead of Objects explicitly, not sure what to do here, because all Arrays are sparse Arrays, so iterating over them in a normal for-loop isn't a good idea. And using hasOwnProperty(..) should be avoided too, as it will affect performance. 
Plus: Removed the IE-workaround in LzParam, no longer needed due to the new class structure.
    

Tests:



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs	2008-08-12 18:20:33 UTC (rev 10665)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs	2008-08-12 20:21:13 UTC (rev 10666)
@@ -672,24 +672,23 @@
    Produce a hash table of key-value pairs.
    In the case of a duplicated key, creates an array of values.
 */
-static function queryStringToTable ( query ) {
-  var queries = {};
-  var parameters = query.split('&');
-  for (var i in parameters) {
-    var key = parameters[i];
-    var value = '';
-    var n = key.indexOf('=');
+static function queryStringToTable ( query:String ) :Object {
+  var queries:Object = {};
+  var parameters:Array = query.split('&');
+  for (var i = 0; i < parameters.length; ++i) {
+    var key:String = parameters[i];
+    var value:String = '';
+    var n:int = key.indexOf('=');
     if (n > 0) {
       value = unescape(key.substring(n+1));
       key = key.substring(0, n);
     }
     if (key in queries) {
-        var prev = queries[key];
+        var prev:* = queries[key];
         if (prev instanceof Array) {
             prev.push(value);
         } else {
-            value = [prev, value];
-            queries[key] = value;
+            queries[key] = [prev, value];
         }
     } else {
         queries[key] = value;

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs	2008-08-12 18:20:33 UTC (rev 10665)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs	2008-08-12 20:21:13 UTC (rev 10666)
@@ -25,10 +25,6 @@
   * @lzxname httpdataprovider
   *
   */
-
-
-
-
 class LzHTTPDataProvider extends LzDataProvider {
 
     function LzHTTPDataProvider ( parent:* = null, attrs:* = null, children:* = null, instcall:*  = null) {
@@ -38,7 +34,6 @@
     /** @access private
      * @param LzHTTPDataRequest dreq: The data request
      */
-
     function makeLoader ( dreq ) {
         var proxied = dreq.proxied;
         // If there is no loader, or if the loader changed it's proxied
@@ -157,9 +152,9 @@
 
         var postbody = dreq.postbody;
         if (postbody == null && qparams != null) {
-            var names = qparams.getNames();
-            for ( var i in names ){
-                var name = names[i];
+            var names:Array = qparams.getNames();
+            for ( var i:int = 0; i < names.length; ++i ){
+                var name:String = names[i];
                 q += sep + name + '=' + encodeURIComponent(qparams.getValue(name));
                 sep = '&';
             }

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzParam.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzParam.lzs	2008-08-12 18:20:33 UTC (rev 10665)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzParam.lzs	2008-08-12 20:21:13 UTC (rev 10666)
@@ -49,7 +49,7 @@
 //setters.$hasdefaultattrs = -1;
 
 /** @access private */
-var d:* = null;
+var d:Object = null;
 
 
 /**
@@ -68,13 +68,13 @@
   * Parse a URL query string, returns an object with key-value pairs
   * @return Object
   */
-static function parseQueryString ( query ) {
-  var parameters = query.split('&');
-  var queries = {};
-  for (var i in parameters) {
-    var key = parameters[i];
-    var value = '';
-    var n = key.indexOf('=');
+static function parseQueryString ( query:String ) :Object {
+  var parameters:Array = query.split('&');
+  var queries:Object = {};
+  for (var i:int = 0; i < parameters.length; ++i) {
+    var key:String = parameters[i];
+    var value:String = '';
+    var n:int = key.indexOf('=');
     if (n > 0) {
       value = unescape(key.substring(n+1));
       key = key.substring(0, n);
@@ -334,7 +334,4 @@
 
 } // End of LzParam
 
-// Fixes LPP-3030 toString() in IE 6+ - the function declaration doesn't work...
-// FIXME: [2008-03-31 pbr] Is this needed?
-LzParam.prototype.toString = LzParam.prototype.serialize;
 lz[LzParam.tagname] = LzParam;  // publish

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzDebug.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzDebug.lzs	2008-08-12 18:20:33 UTC (rev 10665)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/debugger/LzDebug.lzs	2008-08-12 20:21:13 UTC (rev 10666)
@@ -425,7 +425,7 @@
     Debug.error("Backtraces must be on to report a bug.  Please enable backtracing and try again.");
     return;
   }
-  var inspected = [];
+  var inspected = {};
   function inspect (obj, verbose) {
     var id = verbose && Debug.IDForObject(obj);
     if (id && (! (id in inspected))) {
@@ -447,13 +447,14 @@
         Debug.format("\n  arg %2d: %#w", i, inspect(args[i], verbose));
       }
     });
-  if (inspected.length > 0) {
+  var keys = [];
+  // Present the object's in ID-order so they are easier to find.
+  for (var id in inspected) {
+    keys.push(id);
+  }
+  if (keys.length > 0) {
     Debug.format("\n\nOBJECT DETAILS:");
-    var keys = [];
-    // Present the object's in ID-order so they are easier to find.
-    for (var id in inspected) {
-      keys.push(id);
-    }
+    
     keys.sort(function (a, b) {
         var al = parseInt(a);
         var bl = parseInt(b);

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzFontManager.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzFontManager.as	2008-08-12 18:20:33 UTC (rev 10665)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzFontManager.as	2008-08-12 20:21:13 UTC (rev 10666)
@@ -176,7 +176,7 @@
     if (this.__clientFontNames == null) {
         this.__clientFontNames = {};
         var fonts = TextField.getFontList()
-        for (var i in fonts) {
+        for (var i = 0; i < fonts.length; ++i) {
             this.__clientFontNames[fonts[i]] = true;
         }
     }

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/LzFocus.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/LzFocus.lzs	2008-08-12 18:20:33 UTC (rev 10665)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/LzFocus.lzs	2008-08-12 20:21:13 UTC (rev 10666)
@@ -357,15 +357,14 @@
                && root != root.immediateparent)
             root = root.immediateparent;
         // collect selectable children into focusgroup
-        var focusgroup = [];
+        var focusgroup:Array = [];
         this.accumulateSubviews(focusgroup, root, v, true);
 
         // set index to the index of v within the current focus group.
-        var index = -1;
-        for (var i in focusgroup)
+        var index:int = -1;
+        for (var i:int = 0; i < focusgroup.length; ++i)
             if (focusgroup[i] == v) {
-                // for..in returns strings
-                index = Number(i);
+                index = i;
                 break;
             }
 

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/LzTrack.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/LzTrack.lzs	2008-08-12 18:20:33 UTC (rev 10665)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/LzTrack.lzs	2008-08-12 20:21:13 UTC (rev 10666)
@@ -207,19 +207,22 @@
   * simultaneously. This is useful for tracking mechanisms like menus.
   * @param String group: the name of the track group to activate
   */
-function activate ( group ){
-    if (this.__LZactivegroups.length == 0) {
+function activate ( group:String ){
+    var agroups:Array = this.__LZactivegroups;
+    if (agroups.length == 0) {
         // don't want to re-register, in case we are just switching active groups
         this.__LZtrackDel.register( lz.Idle, "onidle" );
     }
     // see if group is already active
-    var found = false;
-    for (var i in this.__LZactivegroups) {
-        if (this.__LZactivegroups[i] == this.__LZreg[group]) found = true;
+    var reg:Object = this.__LZreg;
+    for (var i:int = 0; i < agroups.length; ++i) {
+        if (agroups[i] == reg[group]) {
+            // nothing to do, group is already active
+            return;
+        }
     }
-    if (!found) { //group was not active so put it onto activegroups array
-        this.__LZactivegroups.push(this.__LZreg[group]);
-    }
+    // group was not active so put it onto activegroups array
+    agroups.push(reg[group]);
 }
 
 /**
@@ -227,16 +230,18 @@
   * @param String group: the name of the track group to deactivate
   */
 function deactivate ( group ) {
-    for (var i in this.__LZactivegroups) {
-        if (this.__LZactivegroups[i] == this.__LZreg[group]) {
-            this.__LZactivegroups.splice(i, 1);
+    var agroups:Array = this.__LZactivegroups;
+    var reg:Object = this.__LZreg;
+    for (var i:int = 0; i < agroups.length; ++i) {
+        if (agroups[i] == reg[group]) {
+            agroups.splice(i, 1);
          }
     }
-    if ( this.__LZactivegroups.length == 0) {
+    if (agroups.length == 0) {
       this.__LZtrackDel.unregisterAll();
     }
-    if (typeof(this.__LZreg[group]) != "undefined") {
-        this.__LZreg[group].__LZlasthit = null;   // should send ontrackmouseout ?
+    if (typeof(reg[group]) != "undefined") {
+        reg[group].__LZlasthit = null;   // should send ontrackmouseout ?
     }
 }
 
@@ -311,10 +316,9 @@
   * called on idle when the mouse is down, sends events to topmost view
   * NOTE: it would be good to have bounding rectangles on these groups
   */
-function __LZtrack (ignore)
-{
+function __LZtrack (ignore) {
     var foundviews = [];
-    for ( var i in this.__LZactivegroups ) {
+    for (var i:int = 0; i < this.__LZactivegroups.length; ++i) {
         var hitlist =[];
         //would love to check to see if the mouse is within a group's 
         //bounding rect. this would significantly speed up menu tracking.
@@ -343,9 +347,9 @@
             }
         }
     } 
-    var l = foundviews.length;
-    if ( l ) {
-        for (var i=0; i < l; i++) {
+    var len = foundviews.length;
+    if ( len ) {
+        for (var i=0; i < len; i++) {
             var v = foundviews[i]
             if (v.onmousetrackover.ready) v.onmousetrackover.sendEvent( v );
         }
@@ -356,10 +360,9 @@
   * @access private
   * called before mouseup event is sent
   */
-function __LZmouseup(ignore)
-{
+function __LZmouseup(ignore) {
     //Debug.info('lz.Track.__LZmouseup');
-    for (var i in this.__LZactivegroups) {
+    for (var i:int = 0; i < this.__LZactivegroups.length; ++i) {
         var thisgroup = this.__LZactivegroups[i];
         //Debug.info('i', i, thisgroup, thisgroup.__LZlasthit, thisgroup.__LZlasthit.onmousetrackup);
         if (thisgroup && thisgroup.__LZlasthit) {



More information about the Laszlo-checkins mailing list