You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2014/01/03 08:32:45 UTC

git commit: [flex-sdk] [refs/heads/develop] - remove try and catch to improve performance

Updated Branches:
  refs/heads/develop 7e101d8de -> 9f8aab867


remove try and catch to improve performance


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/9f8aab86
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/9f8aab86
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/9f8aab86

Branch: refs/heads/develop
Commit: 9f8aab8675dc3288be9b1b906da64b5c91728d70
Parents: 7e101d8
Author: Justin Mclean <jm...@apache.org>
Authored: Fri Jan 3 18:31:44 2014 +1100
Committer: Justin Mclean <jm...@apache.org>
Committed: Fri Jan 3 18:31:44 2014 +1100

----------------------------------------------------------------------
 .../controls/dataGridClasses/DataGridColumn.as  | 50 ++++++++++----------
 1 file changed, 24 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9f8aab86/frameworks/projects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as b/frameworks/projects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
index a053c04..8a4a209 100644
--- a/frameworks/projects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
+++ b/frameworks/projects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
@@ -1739,17 +1739,17 @@ public class DataGridColumn extends CSSStyleDeclaration implements IIMESupport
 
         if (typeof(data) == "object" || typeof(data) == "xml")
         {
-            try
-            {
-                if (!hasComplexFieldName) 
-                	data = data[dataField];
-                else 
-                    data = deriveComplexColumnData(data);
-            }
-            catch(e:Error)
-            {
-                data = null;
-            }
+            if (hasComplexFieldName)
+			{
+				data = deriveComplexColumnData(data);
+			}
+			else if (dataField != null)
+			{
+				if (dataField in data)
+	            	data = data[dataField];
+	            else 
+					data = null;
+			}
         }
 
         if (data is String)
@@ -1798,17 +1798,13 @@ public class DataGridColumn extends CSSStyleDeclaration implements IIMESupport
             var field:String = dataTipField;
             if (!field)
                 field = owner.dataTipField;
-            try
-            {
-                if (data[field] != null)
-                    data = data[field];
-                else if (data[dataField] != null)
-                    data = data[dataField];
-            }
-            catch(e:Error)
-            {
-                data = null;
-            }
+
+            if (field in data && data[field] != null)
+                data = data[field];
+            else if (dataField in data && data[dataField] != null)
+                data = data[dataField];
+			else
+				data = null;
         }
 
         if (data is String)
@@ -1828,13 +1824,15 @@ public class DataGridColumn extends CSSStyleDeclaration implements IIMESupport
     /**
      * @private
      */
-    protected function deriveComplexColumnData( data:Object ):Object 
+    protected function deriveComplexColumnData(data:Object):Object 
     {
         var currentRef:Object = data;
-        if ( complexFieldNameComponents ) 
+		var length:int = complexFieldNameComponents.length
+		
+        if (complexFieldNameComponents) 
         {
-            for ( var i:int=0; currentRef && i < complexFieldNameComponents.length; i++ )
-                currentRef = currentRef[ complexFieldNameComponents[ i ] ];
+            for (var i:int=0; currentRef && i < length; i++)
+                currentRef = currentRef[complexFieldNameComponents[i]];
         }
         
         return currentRef?currentRef:"";


Re: git commit: [flex-sdk] [refs/heads/develop] - remove try and catch to improve performance

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> Well in the Adobe days we'd put the code change behind a version flag.  I
> never liked those flags if they controlled more than one code path because
> you had to take all new code paths or none.
I also dislike that them but it is a solution, I think there only been one or two done since donation.

> Lately I've put static flags in the class in question so you can change
> the code paths that way.
> 
> So, if you create a getDataSafely() function with the try/catch in it and
> hide that behind a flag then folks can revert back to old behavior if
> necessary.

Seems the best way - generally knowing about RTEs in your code is good thing.

Thanks,
Justin

Re: git commit: [flex-sdk] [refs/heads/develop] - remove try and catch to improve performance

Posted by Alex Harui <ah...@adobe.com>.
Bummer.

Well in the Adobe days we'd put the code change behind a version flag.  I
never liked those flags if they controlled more than one code path because
you had to take all new code paths or none.

Lately I've put static flags in the class in question so you can change
the code paths that way.

So, if you create a getDataSafely() function with the try/catch in it and
hide that behind a flag then folks can revert back to old behavior if
necessary.

-Alex

On 1/4/14 4:23 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:

>Hi,
>
>OK I tried it out and yes for 4.11 it silently discards any RTEs that
>occur in user's getter code. The changes in develop mean that you will
>see a RTE if one occurs in a user getter.
>
>Thanks,
>Justin


Re: git commit: [flex-sdk] [refs/heads/develop] - remove try and catch to improve performance

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

OK I tried it out and yes for 4.11 it silently discards any RTEs that occur in user's getter code. The changes in develop mean that you will see a RTE if one occurs in a user getter.

Thanks,
Justin

Re: git commit: [flex-sdk] [refs/heads/develop] - remove try and catch to improve performance

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> Did you actually try it?
With a getter no - I'll give it a go. 

All the ADG/DG tests pass - is there a test for getter in there?

Thanks,
Justin

Re: git commit: [flex-sdk] [refs/heads/develop] - remove try and catch to improve performance

Posted by Alex Harui <ah...@adobe.com>.
Did you actually try it?  I seem to recall people complaining about
actually getting an uncaught error so maybe if you have a bug there it
will cause a problem much sooner.

On 1/3/14 3:02 PM, "Justin Mclean" <ju...@classsoftware.com> wrote:

>Hi,
>
>> I wish I'd thought of this last night, but the try/catch also absorbs
>> errors in getters,
>See what you mean now. If you data field is set to a user defined setter
>and that RTEs before the error would get silently eaten.
>
>That seems like a bad idea to me but it is existing SDK behaviour. So do
>we keep the change or not? Any opinions?
>
>Pros:
>- less CG
>- slightly faster
>- (IMO) tell users about issues in their code
>
>Thanks,
>Justin


Re: git commit: [flex-sdk] [refs/heads/develop] - remove try and catch to improve performance

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> I wish I'd thought of this last night, but the try/catch also absorbs
> errors in getters,
See what you mean now. If you data field is set to a user defined setter and that RTEs before the error would get silently eaten.

That seems like a bad idea to me but it is existing SDK behaviour. So do we keep the change or not? Any opinions?

Pros:
- less CG
- slightly faster
- (IMO) tell users about issues in their code

Thanks,
Justin

Re: git commit: [flex-sdk] [refs/heads/develop] - remove try and catch to improve performance

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> I wish I'd thought of this last night, but the try/catch also absorbs
> errors in getters, so these changes could break folks who've been relying
> on that fact.
Sorry lost me - which getters?

Thanks,
Justin

Re: git commit: [flex-sdk] [refs/heads/develop] - remove try and catch to improve performance

Posted by Alex Harui <ah...@adobe.com>.
I wish I'd thought of this last night, but the try/catch also absorbs
errors in getters, so these changes could break folks who've been relying
on that fact.

Lots of folks have getters that don't have null checks and other stuff
like that, although it may be that an exception will get thrown earlier
since folks usually complain on the forums about that.

-Alex

On 1/2/14 11:32 PM, "jmclean@apache.org" <jm...@apache.org> wrote:

>Updated Branches:
>  refs/heads/develop 7e101d8de -> 9f8aab867
>
>
>remove try and catch to improve performance
>
>
>Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
>Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/9f8aab86
>Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/9f8aab86
>Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/9f8aab86
>
>Branch: refs/heads/develop
>Commit: 9f8aab8675dc3288be9b1b906da64b5c91728d70
>Parents: 7e101d8
>Author: Justin Mclean <jm...@apache.org>
>Authored: Fri Jan 3 18:31:44 2014 +1100
>Committer: Justin Mclean <jm...@apache.org>
>Committed: Fri Jan 3 18:31:44 2014 +1100
>
>----------------------------------------------------------------------
> .../controls/dataGridClasses/DataGridColumn.as  | 50 ++++++++++----------
> 1 file changed, 24 insertions(+), 26 deletions(-)
>----------------------------------------------------------------------
>
>
>http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9f8aab86/frameworks/p
>rojects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
>----------------------------------------------------------------------
>diff --git 
>a/frameworks/projects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
> 
>b/frameworks/projects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
>index a053c04..8a4a209 100644
>--- 
>a/frameworks/projects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
>+++ 
>b/frameworks/projects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
>@@ -1739,17 +1739,17 @@ public class DataGridColumn extends
>CSSStyleDeclaration implements IIMESupport
> 
>         if (typeof(data) == "object" || typeof(data) == "xml")
>         {
>-            try
>-            {
>-                if (!hasComplexFieldName)
>-                	data = data[dataField];
>-                else
>-                    data = deriveComplexColumnData(data);
>-            }
>-            catch(e:Error)
>-            {
>-                data = null;
>-            }
>+            if (hasComplexFieldName)
>+			{
>+				data = deriveComplexColumnData(data);
>+			}
>+			else if (dataField != null)
>+			{
>+				if (dataField in data)
>+	            	data = data[dataField];
>+	            else
>+					data = null;
>+			}
>         }
> 
>         if (data is String)
>@@ -1798,17 +1798,13 @@ public class DataGridColumn extends
>CSSStyleDeclaration implements IIMESupport
>             var field:String = dataTipField;
>             if (!field)
>                 field = owner.dataTipField;
>-            try
>-            {
>-                if (data[field] != null)
>-                    data = data[field];
>-                else if (data[dataField] != null)
>-                    data = data[dataField];
>-            }
>-            catch(e:Error)
>-            {
>-                data = null;
>-            }
>+
>+            if (field in data && data[field] != null)
>+                data = data[field];
>+            else if (dataField in data && data[dataField] != null)
>+                data = data[dataField];
>+			else
>+				data = null;
>         }
> 
>         if (data is String)
>@@ -1828,13 +1824,15 @@ public class DataGridColumn extends
>CSSStyleDeclaration implements IIMESupport
>     /**
>      * @private
>      */
>-    protected function deriveComplexColumnData( data:Object ):Object
>+    protected function deriveComplexColumnData(data:Object):Object
>     {
>         var currentRef:Object = data;
>-        if ( complexFieldNameComponents )
>+		var length:int = complexFieldNameComponents.length
>+		
>+        if (complexFieldNameComponents)
>         {
>-            for ( var i:int=0; currentRef && i <
>complexFieldNameComponents.length; i++ )
>-                currentRef = currentRef[ complexFieldNameComponents[ i ]
>];
>+            for (var i:int=0; currentRef && i < length; i++)
>+                currentRef = currentRef[complexFieldNameComponents[i]];
>         }
>         
>         return currentRef?currentRef:"";
>


Re: git commit: [flex-sdk] [refs/heads/develop] - remove try and catch to improve performance

Posted by Alex Harui <ah...@adobe.com>.
I wish I'd thought of this last night, but the try/catch also absorbs
errors in getters, so these changes could break folks who've been relying
on that fact.

Lots of folks have getters that don't have null checks and other stuff
like that, although it may be that an exception will get thrown earlier
since folks usually complain on the forums about that.

-Alex

On 1/2/14 11:32 PM, "jmclean@apache.org" <jm...@apache.org> wrote:

>Updated Branches:
>  refs/heads/develop 7e101d8de -> 9f8aab867
>
>
>remove try and catch to improve performance
>
>
>Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
>Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/9f8aab86
>Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/9f8aab86
>Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/9f8aab86
>
>Branch: refs/heads/develop
>Commit: 9f8aab8675dc3288be9b1b906da64b5c91728d70
>Parents: 7e101d8
>Author: Justin Mclean <jm...@apache.org>
>Authored: Fri Jan 3 18:31:44 2014 +1100
>Committer: Justin Mclean <jm...@apache.org>
>Committed: Fri Jan 3 18:31:44 2014 +1100
>
>----------------------------------------------------------------------
> .../controls/dataGridClasses/DataGridColumn.as  | 50 ++++++++++----------
> 1 file changed, 24 insertions(+), 26 deletions(-)
>----------------------------------------------------------------------
>
>
>http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/9f8aab86/frameworks/p
>rojects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
>----------------------------------------------------------------------
>diff --git 
>a/frameworks/projects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
> 
>b/frameworks/projects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
>index a053c04..8a4a209 100644
>--- 
>a/frameworks/projects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
>+++ 
>b/frameworks/projects/mx/src/mx/controls/dataGridClasses/DataGridColumn.as
>@@ -1739,17 +1739,17 @@ public class DataGridColumn extends
>CSSStyleDeclaration implements IIMESupport
> 
>         if (typeof(data) == "object" || typeof(data) == "xml")
>         {
>-            try
>-            {
>-                if (!hasComplexFieldName)
>-                	data = data[dataField];
>-                else
>-                    data = deriveComplexColumnData(data);
>-            }
>-            catch(e:Error)
>-            {
>-                data = null;
>-            }
>+            if (hasComplexFieldName)
>+			{
>+				data = deriveComplexColumnData(data);
>+			}
>+			else if (dataField != null)
>+			{
>+				if (dataField in data)
>+	            	data = data[dataField];
>+	            else
>+					data = null;
>+			}
>         }
> 
>         if (data is String)
>@@ -1798,17 +1798,13 @@ public class DataGridColumn extends
>CSSStyleDeclaration implements IIMESupport
>             var field:String = dataTipField;
>             if (!field)
>                 field = owner.dataTipField;
>-            try
>-            {
>-                if (data[field] != null)
>-                    data = data[field];
>-                else if (data[dataField] != null)
>-                    data = data[dataField];
>-            }
>-            catch(e:Error)
>-            {
>-                data = null;
>-            }
>+
>+            if (field in data && data[field] != null)
>+                data = data[field];
>+            else if (dataField in data && data[dataField] != null)
>+                data = data[dataField];
>+			else
>+				data = null;
>         }
> 
>         if (data is String)
>@@ -1828,13 +1824,15 @@ public class DataGridColumn extends
>CSSStyleDeclaration implements IIMESupport
>     /**
>      * @private
>      */
>-    protected function deriveComplexColumnData( data:Object ):Object
>+    protected function deriveComplexColumnData(data:Object):Object
>     {
>         var currentRef:Object = data;
>-        if ( complexFieldNameComponents )
>+		var length:int = complexFieldNameComponents.length
>+		
>+        if (complexFieldNameComponents)
>         {
>-            for ( var i:int=0; currentRef && i <
>complexFieldNameComponents.length; i++ )
>-                currentRef = currentRef[ complexFieldNameComponents[ i ]
>];
>+            for (var i:int=0; currentRef && i < length; i++)
>+                currentRef = currentRef[complexFieldNameComponents[i]];
>         }
>         
>         return currentRef?currentRef:"";
>