flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: git commit: [flex-sdk] [refs/heads/develop] - FIX - FLEX-33865 ConstraintLayout optimization
Date Mon, 04 Nov 2013 17:57:48 GMT
Just thinking:  I know you've spent a lot of time on this (and thanks for
doing so), but is Array really being used just to pass two values?  I
wonder if it would be better to use Point.

On 11/4/13 12:55 AM, "mamsellem@apache.org" <mamsellem@apache.org> wrote:

>Updated Branches:
>  refs/heads/develop 5c9baf119 -> 7cab71bb2
>
>
>FIX - FLEX-33865 ConstraintLayout optimization
>
>
>Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
>Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/7cab71bb
>Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/7cab71bb
>Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/7cab71bb
>
>Branch: refs/heads/develop
>Commit: 7cab71bb2192390dceaa4cc4c07eb45f49a4f5c7
>Parents: 5c9baf1
>Author: mamsellem <maurice.amsellem@systar.com>
>Authored: Mon Nov 4 09:52:05 2013 +0100
>Committer: mamsellem <maurice.amsellem@systar.com>
>Committed: Mon Nov 4 09:52:05 2013 +0100
>
>----------------------------------------------------------------------
> .../spark/src/spark/layouts/ConstraintLayout.as | 17 ++---
> .../supportClasses/LayoutElementHelper.as       | 78 ++++++++++++++++----
> 2 files changed, 72 insertions(+), 23 deletions(-)
>----------------------------------------------------------------------
>
>
>http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/7cab71bb/frameworks/p
>rojects/spark/src/spark/layouts/ConstraintLayout.as
>----------------------------------------------------------------------
>diff --git 
>a/frameworks/projects/spark/src/spark/layouts/ConstraintLayout.as
>b/frameworks/projects/spark/src/spark/layouts/ConstraintLayout.as
>index c7d47a6..60ef4cd 100644
>--- a/frameworks/projects/spark/src/spark/layouts/ConstraintLayout.as
>+++ b/frameworks/projects/spark/src/spark/layouts/ConstraintLayout.as
>@@ -605,7 +605,7 @@ public class ConstraintLayout extends LayoutBase
>         if (value == null)
>             return;
>         
>-        var constraintColumns:Vector.<ConstraintColumn> =
>this.constraintColumns;
>+        var constraintColumns:Vector.<ConstraintColumn> =
>this._constraintColumns;
>         var numCols:int = constraintColumns.length;
>         var totalWidth:Number = 0;
>         
>@@ -626,7 +626,7 @@ public class ConstraintLayout extends LayoutBase
>         if (value == null)
>             return;
>         
>-        var constraintRows:Vector.<ConstraintRow> = this.constraintRows;
>+        var constraintRows:Vector.<ConstraintRow> = this._constraintRows;
>         var numRows:int = constraintRows.length;
>         var totalHeight:Number = 0;
>         
>@@ -1669,24 +1669,23 @@ public class ConstraintLayout extends LayoutBase
>         
>         var message:String;
>         
>-        var temp:Array;
>-        temp = 
>LayoutElementHelper.parseConstraintExp(layoutElement.left);
>+        var temp:Array =
>LayoutElementHelper.parseConstraintExp(layoutElement.left);
>         left = temp[0];
>         leftBoundary = temp[1];
>         
>-        temp = 
>LayoutElementHelper.parseConstraintExp(layoutElement.right);
>+        temp = 
>LayoutElementHelper.parseConstraintExp(layoutElement.right, temp);
>         right = temp[0];
>         rightBoundary = temp[1];
>         
>-        temp = LayoutElementHelper.parseConstraintExp(layoutElement.top);
>+        temp = LayoutElementHelper.parseConstraintExp(layoutElement.top,
>temp);
>         top = temp[0];
>         topBoundary = temp[1];
>         
>-        temp = 
>LayoutElementHelper.parseConstraintExp(layoutElement.bottom);
>+        temp = 
>LayoutElementHelper.parseConstraintExp(layoutElement.bottom, temp);
>         bottom = temp[0];
>         bottomBoundary = temp[1];
>         
>-        temp = 
>LayoutElementHelper.parseConstraintExp(layoutElement.baseline);
>+        temp = 
>LayoutElementHelper.parseConstraintExp(layoutElement.baseline, temp);
>         baseline = temp[0];
>         baselineBoundary = temp[1];
>         
>@@ -1938,4 +1937,4 @@ import mx.containers.utilityClasses.FlexChildInfo;
> class ConstraintRegionFlexChildInfo extends FlexChildInfo
> {
>     public var index:int
>-}
>\ No newline at end of file
>+}
>
>http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/7cab71bb/frameworks/p
>rojects/spark/src/spark/layouts/supportClasses/LayoutElementHelper.as
>----------------------------------------------------------------------
>diff --git 
>a/frameworks/projects/spark/src/spark/layouts/supportClasses/LayoutElement
>Helper.as 
>b/frameworks/projects/spark/src/spark/layouts/supportClasses/LayoutElement
>Helper.as
>index baab217..d8eac93 100644
>--- 
>a/frameworks/projects/spark/src/spark/layouts/supportClasses/LayoutElement
>Helper.as
>+++ 
>b/frameworks/projects/spark/src/spark/layouts/supportClasses/LayoutElement
>Helper.as
>@@ -19,6 +19,7 @@
> 
> package spark.layouts.supportClasses
> {
>+import mx.utils.StringUtil;
> 
> [ExcludeClass]
> 
>@@ -79,28 +80,77 @@ public class LayoutElementHelper
>      *  so that an array is returned where the first value is
>      *  the offset (ie: 10) and the second value is
>      *  the boundary (ie: "col1")
>+     *  @arg result :  optional Array to save an Array memory allocation
>      */
>-    public static function parseConstraintExp(val:Object):Array
>+    public static function parseConstraintExp(val:Object,
>result:Array=null):Array
>     {
>-        if (val is Number)
>-            return [Number(val), null];
>-        
>-        if (!val)
>-            return [NaN, null];
>-        // Replace colons with spaces
>-        var temp:String = String(val).replace(/:/g, " ");
>-        
>-        // Split the string into an array
>-        var args:Array = temp.split(/\s+/);
>+        // number
>+        if (val is Number) {
>+            if(result == null) {
>+                return [val as Number, null];
>+            }
>+            else {
>+                result[0] = val as Number;
>+                result[1] = null;
>+                return result;
>+            }
>+        }
>+       // null
>+        if (!val) {
>+            if(result == null) {
>+                return [NaN, null];
>+            }
>+            else {
>+                result[0] = NaN;
>+                result[1] = null;
>+                return result;
>+            }
>+        }
>+
>+        // String case  : 2 sub-cases, number of constraint
>+        var tmp:String = String(val);
>+        var colonPos:int = tmp.indexOf(":");
>         
>         // If the val was a String object representing a single number
>(i.e. "100"),
>         // then we'll hit this case:
>-        if (args.length == 1)
>-            return args;
>+        if(colonPos == -1) {
>+            return [StringUtil.trim(tmp)];
>+        }
>         
>         // Return [offset, boundary]
>-        return [args[1], args[0]];
>+        if(result == null) {
>+            result =[];
>+        }
>+        
>+        //here we do not use StringUtil in order to avoid unnecessary
>memory allocations
>+        var startIndex:int = 0;
>+        while (StringUtil.isWhitespace(tmp.charAt(startIndex))) {
>+            ++startIndex;
>+        }
>+        
>+        var endIndex:int = tmp.length - 1;
>+        while (StringUtil.isWhitespace(tmp.charAt(endIndex) )) {
>+            --endIndex;
>+        }
>+        
>+        var endIndexPart1:int = colonPos-1;
>+        while (StringUtil.isWhitespace(tmp.charAt(endIndexPart1))) {
>+            --endIndexPart1;
>+        }
>+        
>+        var startIndexPart2:int = colonPos+1;
>+        while (StringUtil.isWhitespace(tmp.charAt(startIndexPart2))) {
>+            ++startIndexPart2;
>+        }
>+        
>+        result[0] = tmp.substring(startIndexPart2, endIndex+1);
>+        result[1] = tmp.substring(startIndex, endIndexPart1+1);
>+        
>+        return result;
>     }
>+
>+
>+
> }
> 
> }
>


Mime
View raw message