make getValue a lot faster - 30ms down to 5ms in a complex app for JS in Chrome


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/5e0d3305
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/5e0d3305
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/5e0d3305

Branch: refs/heads/develop
Commit: 5e0d33052ad6105cd92b18e1ce800674ce1ccec9
Parents: bdbffb8
Author: Justin Mclean <jmcl...@apache.org>
Authored: Thu Jun 1 15:58:01 2017 +1000
Committer: Justin Mclean <jmcl...@apache.org>
Committed: Thu Jun 1 15:58:01 2017 +1000

----------------------------------------------------------------------
 .../org/apache/flex/core/SimpleCSSValuesImpl.as | 43 ++++++++------------
 1 file changed, 18 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5e0d3305/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as
----------------------------------------------------------------------
diff --git 
a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as
 
b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as
index 6d4adec..a4e4e1d 100644
--- 
a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as
+++ 
b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as
@@ -99,8 +99,8 @@ package org.apache.flex.core
             while (true)
             {
                 var ffName:String = "factoryFunctions" + i.toString();
-                var ff:Object = c[ffName];
-                if (ff === null)
+                var ff:* = c[ffName];
+                if (ff === undefined)
                     break;
                 generateCSSStyleDeclarations(c[ffName], c["data" + 
i.toString()]);
                 if (hasEventListener("init"))
@@ -164,9 +164,7 @@ package org.apache.flex.core
         COMPILE::SWF
         public function generateCSSStyleDeclarations(factoryFunctions:Object, 
arr:Array):void
         {
-                       if (factoryFunctions === null)
-                               return;
-                       if (arr === null)
+                       if (factoryFunctions === null || arr === null)
                                return;
                        
             var declarationName:String = "";
@@ -331,30 +329,25 @@ package org.apache.flex.core
             }
 
             var value:*;
-                       var o:Object;
+                       var o:*;
                        var className:String;
                        var selectorName:String;
                        
                        if (thisObject is IStyleableObject)
                        {
                 var styleable:IStyleableObject = IStyleableObject(thisObject);
-                if (styleable.style !== null)
+                if (styleable.style !== undefined)
                 {
-                    try {
-                        value = styleable.style[valueName];
-                    }
-                    catch (e:Error) {
-                        value = undefined;
-                    }
+                    value = styleable.style[valueName];
                     if (value === INHERIT)
                         return getInheritingValue(thisObject, valueName, 
state, attrs);
                     if (value !== undefined)
                         return value;
                 }
-                if (styleable.id !== null)
+                if (styleable.id !== undefined)
                 {
                     o = values["#" + styleable.id];
-                    if (o)
+                    if (o !== undefined)
                     {
                         value = o[valueName];
                         if (value === INHERIT)
@@ -364,16 +357,16 @@ package org.apache.flex.core
                     }                    
                 }
                                var classNames:String = styleable.className;
-                if (classNames)
+                if (classNames !== undefined)
                 {
                     var classNameList:Array = classNames.split(" ");
                     for each (className in classNameList)
                     {
-                        if (state)
+                        if (state !== null)
                         {
                             selectorName = className + ":" + state;
                             o = values["." + selectorName];
-                            if (o)
+                            if (o !== undefined)
                             {
                                 value = o[valueName];
                                 if (value === INHERIT)
@@ -384,7 +377,7 @@ package org.apache.flex.core
                         }
                         
                         o = values["." + className];
-                        if (o)
+                        if (o !== undefined)
                         {
                             value = o[valueName];
                             if (value === INHERIT)
@@ -407,11 +400,11 @@ package org.apache.flex.core
             var thisInstance:Object = thisObject;
                        while (className !== "Object")
                        {
-                               if (state)
+                               if (state !== null)
                                {
                                        selectorName = className + ":" + state;
                                        o = values[selectorName];
-                                       if (o)
+                                       if (o !== undefined)
                                        {
                                                value = o[valueName];
                         if (value === INHERIT)
@@ -422,7 +415,7 @@ package org.apache.flex.core
                                }
                                
                    o = values[className];
-                   if (o)
+                   if (o !== undefined)
                    {
                        value = o[valueName];
                     if (value === INHERIT)
@@ -446,7 +439,7 @@ package org.apache.flex.core
                 }
                        }
             
-            if (inheritingStyles[valueName] != null &&
+            if (inheritingStyles[valueName] !== undefined &&
                 thisObject is IChild)
             {
                 var parentObject:Object = IChild(thisObject).parent;
@@ -455,14 +448,14 @@ package org.apache.flex.core
             }
             
             o = values["global"];
-            if (o)
+            if (o !== undefined)
             {
                        value = o[valueName];
                        if (value !== undefined)
                                return value;
             }
                        o = values["*"];                        
-                       if(o)
+                       if (o !== undefined)
                        {
                                return o[valueName];
                        }

Reply via email to