Return-Path: X-Original-To: apmail-flex-dev-archive@www.apache.org Delivered-To: apmail-flex-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 888DF106F5 for ; Mon, 4 Nov 2013 18:13:58 +0000 (UTC) Received: (qmail 62899 invoked by uid 500); 4 Nov 2013 18:13:57 -0000 Delivered-To: apmail-flex-dev-archive@flex.apache.org Received: (qmail 62869 invoked by uid 500); 4 Nov 2013 18:13:57 -0000 Mailing-List: contact dev-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list dev@flex.apache.org Received: (qmail 62861 invoked by uid 99); 4 Nov 2013 18:13:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Nov 2013 18:13:57 +0000 X-ASF-Spam-Status: No, hits=1.0 required=5.0 tests=FRT_ADOBE2,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of maurice.amsellem@systar.com designates 216.134.213.70 as permitted sender) Received: from [216.134.213.70] (HELO smtp01.myhostedservice.com) (216.134.213.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Nov 2013 18:13:53 +0000 Received: from EXHUB04.netplexity.local (172.29.211.24) by smtp01.myhostedservice.com (172.29.211.11) with Microsoft SMTP Server (TLS) id 14.2.347.0; Mon, 4 Nov 2013 13:13:03 -0500 Received: from EXMBX05.netplexity.local ([fe80::cc58:cfe7:ba3b:fae]) by exhub04 ([172.29.211.24]) with mapi id 14.03.0146.000; Mon, 4 Nov 2013 13:13:27 -0500 From: Maurice Amsellem To: "dev@flex.apache.org" Subject: RE: git commit: [flex-sdk] [refs/heads/develop] - FIX - FLEX-33865 ConstraintLayout optimization Thread-Topic: git commit: [flex-sdk] [refs/heads/develop] - FIX - FLEX-33865 ConstraintLayout optimization Thread-Index: Ac7Zh19yL0Y7rfe/QDW6DWH4so4ZPAAAJW7gAAAjKlA= Date: Mon, 4 Nov 2013 18:13:26 +0000 Message-ID: <2095F5EBE04D59409DFCE91FFCEBF7AF3F53FCF8@EXMBX05.netplexity.local> References: <81369150737c4f379655e1fe3ba16094@git.apache.org> <2095F5EBE04D59409DFCE91FFCEBF7AF3F53FCC1@EXMBX05.netplexity.local> In-Reply-To: <2095F5EBE04D59409DFCE91FFCEBF7AF3F53FCC1@EXMBX05.netplexity.local> Accept-Language: fr-FR, en-US Content-Language: fr-FR X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.29.211.254] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org Alex, to be honest, the last "split" tests I did ( code optimization only a= nd code optimization + Array recycling) show that the bulk of the performa= nce gain (10%) comes from the use of indexOf(..) to detect that we are in a= simple "Number case", instead of split+replace which is very costly. All the rest (Array recycling, inlined code, etc...) induces a marginal imp= rovement of 1%. However, I would prefer not to spent time on this issue anymore. Regards, Maurice=20 -----Message d'origine----- De=A0: Maurice Amsellem [mailto:maurice.amsellem@systar.com]=20 Envoy=E9=A0: lundi 4 novembre 2013 19:05 =C0=A0: dev@flex.apache.org; commits@flex.apache.org Objet=A0: RE: git commit: [flex-sdk] [refs/heads/develop] - FIX - FLEX-3386= 5 ConstraintLayout optimization Actually, the values are one Number and optionally one String. So I don't t= hink Point could be used. Maybe a dedicated class ? Maurice=20 -----Message d'origine----- De=A0: Alex Harui [mailto:aharui@adobe.com] Envoy=E9=A0: lundi 4 novembre 2= 013 18:58 =C0=A0: dev@flex.apache.org; commits@flex.apache.org Objet=A0: Re= : git commit: [flex-sdk] [refs/heads/develop] - FIX - FLEX-33865 Constraint= Layout optimization Just thinking: I know you've spent a lot of time on this (and thanks for d= oing 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" 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 >Authored: Mon Nov 4 09:52:05 2013 +0100 >Committer: mamsellem >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/framework >s/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 =3D=3D null) > return; > =20 >- var constraintColumns:Vector. =3D >this.constraintColumns; >+ var constraintColumns:Vector. =3D >this._constraintColumns; > var numCols:int =3D constraintColumns.length; > var totalWidth:Number =3D 0; > =20 >@@ -626,7 +626,7 @@ public class ConstraintLayout extends LayoutBase > if (value =3D=3D null) > return; > =20 >- var constraintRows:Vector. =3D this.constraintRows= ; >+ var constraintRows:Vector. =3D=20 >+ this._constraintRows; > var numRows:int =3D constraintRows.length; > var totalHeight:Number =3D 0; > =20 >@@ -1669,24 +1669,23 @@ public class ConstraintLayout extends=20 >LayoutBase > =20 > var message:String; > =20 >- var temp:Array; >- temp =3D=20 >LayoutElementHelper.parseConstraintExp(layoutElement.left); >+ var temp:Array =3D >LayoutElementHelper.parseConstraintExp(layoutElement.left); > left =3D temp[0]; > leftBoundary =3D temp[1]; > =20 >- temp =3D=20 >LayoutElementHelper.parseConstraintExp(layoutElement.right); >+ temp =3D >LayoutElementHelper.parseConstraintExp(layoutElement.right, temp); > right =3D temp[0]; > rightBoundary =3D temp[1]; > =20 >- temp =3D LayoutElementHelper.parseConstraintExp(layoutElement.top= ); >+ temp =3D >+ LayoutElementHelper.parseConstraintExp(layoutElement.top, >temp); > top =3D temp[0]; > topBoundary =3D temp[1]; > =20 >- temp =3D=20 >LayoutElementHelper.parseConstraintExp(layoutElement.bottom); >+ temp =3D >LayoutElementHelper.parseConstraintExp(layoutElement.bottom, temp); > bottom =3D temp[0]; > bottomBoundary =3D temp[1]; > =20 >- temp =3D=20 >LayoutElementHelper.parseConstraintExp(layoutElement.baseline); >+ temp =3D >LayoutElementHelper.parseConstraintExp(layoutElement.baseline, temp); > baseline =3D temp[0]; > baselineBoundary =3D temp[1]; > =20 >@@ -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/framework >s/p >rojects/spark/src/spark/layouts/supportClasses/LayoutElementHelper.as >---------------------------------------------------------------------- >diff --git >a/frameworks/projects/spark/src/spark/layouts/supportClasses/LayoutElem >ent >Helper.as >b/frameworks/projects/spark/src/spark/layouts/supportClasses/LayoutElem >ent >Helper.as >index baab217..d8eac93 100644 >--- >a/frameworks/projects/spark/src/spark/layouts/supportClasses/LayoutElem >ent >Helper.as >+++=20 >b/frameworks/projects/spark/src/spark/layouts/supportClasses/LayoutElem >ent >Helper.as >@@ -19,6 +19,7 @@ >=20 > package spark.layouts.supportClasses > { >+import mx.utils.StringUtil; >=20 > [ExcludeClass] >=20 >@@ -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=20 >+ allocation > */ >- public static function parseConstraintExp(val:Object):Array >+ public static function parseConstraintExp(val:Object, >result:Array=3Dnull):Array > { >- if (val is Number) >- return [Number(val), null]; >- =20 >- if (!val) >- return [NaN, null]; >- // Replace colons with spaces >- var temp:String =3D String(val).replace(/:/g, " "); >- =20 >- // Split the string into an array >- var args:Array =3D temp.split(/\s+/); >+ // number >+ if (val is Number) { >+ if(result =3D=3D null) { >+ return [val as Number, null]; >+ } >+ else { >+ result[0] =3D val as Number; >+ result[1] =3D null; >+ return result; >+ } >+ } >+ // null >+ if (!val) { >+ if(result =3D=3D null) { >+ return [NaN, null]; >+ } >+ else { >+ result[0] =3D NaN; >+ result[1] =3D null; >+ return result; >+ } >+ } >+ >+ // String case : 2 sub-cases, number of constraint >+ var tmp:String =3D String(val); >+ var colonPos:int =3D tmp.indexOf(":"); > =20 > // If the val was a String object representing a single number=20 >(i.e. "100"), > // then we'll hit this case: >- if (args.length =3D=3D 1) >- return args; >+ if(colonPos =3D=3D -1) { >+ return [StringUtil.trim(tmp)]; >+ } > =20 > // Return [offset, boundary] >- return [args[1], args[0]]; >+ if(result =3D=3D null) { >+ result =3D[]; >+ } >+ =20 >+ //here we do not use StringUtil in order to avoid unnecessary >memory allocations >+ var startIndex:int =3D 0; >+ while (StringUtil.isWhitespace(tmp.charAt(startIndex))) { >+ ++startIndex; >+ } >+ =20 >+ var endIndex:int =3D tmp.length - 1; >+ while (StringUtil.isWhitespace(tmp.charAt(endIndex) )) { >+ --endIndex; >+ } >+ =20 >+ var endIndexPart1:int =3D colonPos-1; >+ while (StringUtil.isWhitespace(tmp.charAt(endIndexPart1))) { >+ --endIndexPart1; >+ } >+ =20 >+ var startIndexPart2:int =3D colonPos+1; >+ while (StringUtil.isWhitespace(tmp.charAt(startIndexPart2))) { >+ ++startIndexPart2; >+ } >+ =20 >+ result[0] =3D tmp.substring(startIndexPart2, endIndex+1); >+ result[1] =3D tmp.substring(startIndex, endIndexPart1+1); >+ =20 >+ return result; > } >+ >+ >+ > } >=20 > } >