History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-4055
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: -- --
Assignee: Unassigned
Reporter: Benjamin Shine
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

constructWithArgs defined twice in LzNode.lzs

Created: 29/May/07 09:34 AM   Updated: 29/Oct/07 02:30 PM
Component/s: LFC - Object System
Affects Version/s: 4.0.2
Fix Version/s: 4.0.5WaffleCone

Time Tracking:
Not Specified

Severity: Minor
Runtime: N/A
Fix in hand: False


 Description  « Hide
I noticed that LzNode.lzs contains two definitions for constructWithArgs, both of which are no-ops, one at line 651, one at line 1959. This seems odd, especially with these two curious comments:
        // TODO: [2006-05-22 ptw] What is the purpose of this copy?
        // construct or constructWithArgs destructively modify args?
and
  * @todo 2006-05-24 ptw Adam says this is a hack that we should get
  * rid of.

At the very least the compile should have given a warning that you were redefining a method.
(There does need to be one definition, since the method is called there has to be a method -- it is overridden somewhere else. But it is an ancient kludge we should stomp out.)


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
André Bargull - 28/Jul/07 03:43 AM
I've stumbled upon this issue today, a search for "constructWithArgs" in the LFC gave this results:

----------------------------------------
lps-4.0.x-src\lps-4.0.3\WEB-INF\lps\lfc\core\LzNode.lzs(183): this.constructWithArgs( maskedargs );
lps-4.0.x-src\lps-4.0.3\WEB-INF\lps\lfc\core\LzNode.lzs(644): function constructWithArgs ( parent , args ){}
lps-4.0.x-src\lps-4.0.3\WEB-INF\lps\lfc\core\LzNode.lzs(1951): function constructWithArgs ( parent , args ){}
----------------------------------------
lps-4.0.x-src\lps-4.0.3\WEB-INF\lps\lfc\data\LzReplicationManager.lzs(279): function constructWithArgs ( args ){
----------------------------------------
lps-4.0.x-src\lps-4.0.3\WEB-INF\lps\lfc\controllers\LaszloLayout.lzs(132): function constructWithArgs ( args ) {
----------------------------------------

So, as reported "constructWithArgs" is declared two times in "LzNode", but additionally the parameter declaration is false in both cases, it should be:
[code]
function constructWithArgs ( args ){}
[/code]

Max Carlson - 03/Aug/07 12:20 PM
Since this is an undocumented API and we do eventually want to eliminate it, I've removed the methods from LzNode altogether. Now, it's not a method override but a method declaration. super calls are not allowed (or required by the LFC implementations)

Max Carlson - 03/Aug/07 12:20 PM
Author: max
Date: 2007-08-02 10:18:46 -0700 (Thu, 02 Aug 2007)
New Revision: 5910

Modified:
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/core/LzNode.lzs
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/events/LaszloEvents.lzs
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/services/LzCSSStyle.js
Log:
 20070801-maxcarlson-V by maxcarlson@plastik on 2007-08-01 20:51:00 PDT
    in /Users/maxcarlson/openlaszlo/wafflecone
    for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone

Summary: More optimization of LFC

New Features:

Bugs Fixed: LPP-4414 - Improve startup performance (partial)

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

Documentation:

Release Notes:

Details: LzCSSStyle.js - Cache getPropertyValueFor() calls. Only call _selectorApplies() for compound css statements.

LzNode.lzs - Only call constructWithArgs() if it exists.

LaszloEvents.lzs - Check for null reference.
    

Tests: ...silver/main.lzx?lzr=dhtml&lzt=html shows ~24029 fewer total calls (252524 total before, 228495 now). http://localhost:8080/wafflecone/test/style/constraints/main.lzx?lzr=swf8 passes as before, shows 405ms for lookup test.



Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/core/LzNode.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/core/LzNode.lzs 2007-08-02 16:46:55 UTC (rev 5909)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/core/LzNode.lzs 2007-08-02 17:18:46 UTC (rev 5910)
@@ -180,7 +180,11 @@
             this.__LZstyleConstraints = this.__LZapplyStyleMap( styleMap, attrs );
         }
 
- this.constructWithArgs( maskedargs );
+ /**
+ * @todo 2006-05-24 ptw Adam says this is a hack that we should get
+ * rid of.
+ */
+ if (this.constructWithArgs) this.constructWithArgs( maskedargs );
 
         delete this.__LZdeferDelegates;
         if (qpos != LzDelegate.__LZdelegatesQueue.length) {
@@ -641,13 +645,6 @@
 }
 
 /**
- * @access private
- * @todo 2006-05-24 ptw Adam says this is a hack that we should get
- * rid of.
- */
-function constructWithArgs ( parent , args ){}
-
-/**
   * Called at the same time that the node sends its oninit event -- usually
   * when the node's siblings are instantiated, and always after the node's
   * children are instantiated.
@@ -1967,10 +1964,4 @@
   this.makeChild( dpobj , true);
 }
 
-
-/**
- * @access private
- */
-function constructWithArgs ( parent , args ){}
-
 } // End of LzNode

Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/events/LaszloEvents.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/events/LaszloEvents.lzs 2007-08-02 16:46:55 UTC (rev 5909)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/events/LaszloEvents.lzs 2007-08-02 17:18:46 UTC (rev 5910)
@@ -215,7 +215,7 @@
       }
       */
       // d.execute( sd ); inlined
- d.c[d.f]( sd );
+ if (d.c[d.f]) d.c[d.f]( sd );
       i+=2;
     }
     evq.length = pos;

Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/services/LzCSSStyle.js
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/services/LzCSSStyle.js 2007-08-02 16:46:55 UTC (rev 5909)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/services/LzCSSStyle.js 2007-08-02 17:18:46 UTC (rev 5910)
@@ -70,6 +70,7 @@
     return 1 ;
 }
 
+LzCSSStyleRule.prototype.__pvcache = {};
 
 var LzCSSStyle = {};
 
@@ -90,6 +91,8 @@
     //var t = getTimer();
     if (!node) return;
     var uid = node.getUID();
+ var val = LzCSSStyleRule.prototype.__pvcache[uid + pname];
+ if (val) return val;
     var rules = this.__LZRuleCache[ uid ];
     if ( !rules ) {
         rules = new Array();
@@ -102,7 +105,7 @@
                  (rp.type == 3 && (((rp.classname in lz) && (node instanceof lz[ rp.classname ])) || ( (rp.classname in global) && (node instanceof global[ rp.classname ])))) ||
                  (rp.type == 5 && node[ rp.attrname ] == rp.attrvalue) ||
                  (rp.type == 6 && node[ rp.attrname ] == rp.attrvalue && (((rp.classname in lz) && (node instanceof lz[ rp.classname ])) || ( (rp.classname in global) && (node instanceof global[ rp.classname ])))) ||
- this._selectorApplies( r, rp, node ) ){
+ (rp.type == 4 && this._selectorApplies( r, rp, node ))){
                 rules.push(r);
             }
         }
@@ -124,7 +127,7 @@
                  (rp.type == 3 && (((rp.classname in lz) && (node instanceof lz[ rp.classname ])) || ( (rp.classname in global) && (node instanceof global[ rp.classname ])))) ||
                  (rp.type == 5 && node[ rp.attrname ] == rp.attrvalue) ||
                  (rp.type == 6 && node[ rp.attrname ] == rp.attrvalue && (((rp.classname in lz) && (node instanceof lz[ rp.classname ])) || ( (rp.classname in global) && (node instanceof global[ rp.classname ])))) ||
- this._selectorApplies( r, rp, node ) ){
+ (rp.type == 4 && this._selectorApplies( r, rp, node ))){
                     rules.push(r);
                 }
             }
@@ -148,7 +151,11 @@
     var i = 0;
     while ( i < l ) {
         var props = rules[i++].properties;
- if (pname in props) { return props[pname]; }
+ if (pname in props) {
+ var v = props[pname];
+ LzCSSStyleRule.prototype.__pvcache[uid + pname] = v
+ return v;
+ }
     }
 
     ////this.time1 += getTimer() - t;
@@ -316,7 +323,7 @@
                                 (inrp.type == 3 && (((inrp.classname in lz) && (icurnode instanceof lz[ inrp.classname ])) || ( (inrp.classname in global) && (icurnode instanceof global[ inrp.classname ])))) ||
                                 (inrp.type == 5 && icurnode[ inrp.attrname ] == inrp.attrvalue) ||
                                 (inrp.type == 6 && icurnode[ inrp.attrname ] == inrp.attrvalue && (((inrp.classname in lz) && (icurnode instanceof lz[ inrp.classname ])) || ( (inrp.classname in global) && (icurnode instanceof global[ inrp.classname ])))) ||
- this._selectorApplies( rule, inrp, icurnode )){
+ (inrp.type == 4 && this._selectorApplies( rule, inrp, icurnode ))){
                                 if ( sindex-- == 0 ){
                                     iresult = true;
                                     break;


_______________________________________________
Laszlo-checkins mailing list
Laszlo-checkins@openlaszlo.org
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Mamye Kratt - 29/Oct/07 02:30 PM
(trunk build r7041)
Fixed, reviewed WEB-INF/lps/lfc/core/LzNode.lzs.