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 2017/06/02 02:04:07 UTC

git commit: [flex-asjs] [refs/heads/develop] - improve comparisons and move end condition calculation out of loop

Repository: flex-asjs
Updated Branches:
  refs/heads/develop 5e0d33052 -> 6f03502df


improve comparisons and move end condition calculation out of loop


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

Branch: refs/heads/develop
Commit: 6f03502df36ca0cd01a269db255b2a5c2cbea6f3
Parents: 5e0d330
Author: Justin Mclean <jm...@apache.org>
Authored: Fri Jun 2 12:03:57 2017 +1000
Committer: Justin Mclean <jm...@apache.org>
Committed: Fri Jun 2 12:03:57 2017 +1000

----------------------------------------------------------------------
 .../org/apache/flex/collections/ArrayList.as    | 26 +++++++++++---------
 .../apache/flex/collections/FlattenedList.as    | 15 ++++++-----
 2 files changed, 24 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6f03502d/frameworks/projects/Collections/src/main/flex/org/apache/flex/collections/ArrayList.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Collections/src/main/flex/org/apache/flex/collections/ArrayList.as b/frameworks/projects/Collections/src/main/flex/org/apache/flex/collections/ArrayList.as
index fe74932..2598dd5 100644
--- a/frameworks/projects/Collections/src/main/flex/org/apache/flex/collections/ArrayList.as
+++ b/frameworks/projects/Collections/src/main/flex/org/apache/flex/collections/ArrayList.as
@@ -93,8 +93,10 @@ package org.apache.flex.collections
 		public function ArrayList(initialSource:Array=null)
 		{
 			super();
-			if (initialSource) _source = initialSource;
-			else _source = [];
+			if (initialSource !== null)
+				_source = initialSource;
+			else
+				_source = [];
 		}
 
         private var _id:String;
@@ -117,7 +119,7 @@ package org.apache.flex.collections
          */
 		public function set id(value:String):void
 		{
-			if (_id != value)
+			if (_id !== value)
 			{
 				_id = value;
 				dispatchEvent(new Event("idChanged"));
@@ -157,8 +159,8 @@ package org.apache.flex.collections
 
 		public function set source(value:Array):void
 		{
-			if (_source != value) {
-				if (value == null)
+			if (_source !== value) {
+				if (value === null)
 				{
 					_source = [];
                 }
@@ -207,8 +209,10 @@ package org.apache.flex.collections
 		 */
 		public function getItemIndex(item:Object):int
 		{
-			for (var index:int=0; index < _source.length; index++) {
-				if (item == _source[index]) {
+			var length:int = _source.length;
+			
+			for (var index:int=0; index < length; index++) {
+				if (item === _source[index]) {
 					return index;
 				}
 			}
@@ -244,11 +248,11 @@ package org.apache.flex.collections
 			{
 				source.splice(index, 0, item);
 			}
-			else if (index == spliceUpperBound)
+			else if (index === spliceUpperBound)
 			{
 				source.push(item);
 			}
-			else if (index == 0)
+			else if (index === 0)
 			{
 				source.unshift(item);
 			}
@@ -328,11 +332,11 @@ package org.apache.flex.collections
 			{
 				removed = source.splice(index, 1)[0];
 			}
-			else if (index == spliceUpperBound)
+			else if (index === spliceUpperBound)
 			{
 				removed = source.pop();
 			}
-			else if (index == 0)
+			else if (index === 0)
 			{
 				removed = source.shift();
 			}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6f03502d/frameworks/projects/Collections/src/main/flex/org/apache/flex/collections/FlattenedList.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Collections/src/main/flex/org/apache/flex/collections/FlattenedList.as b/frameworks/projects/Collections/src/main/flex/org/apache/flex/collections/FlattenedList.as
index f26fd8b..dba38a5 100644
--- a/frameworks/projects/Collections/src/main/flex/org/apache/flex/collections/FlattenedList.as
+++ b/frameworks/projects/Collections/src/main/flex/org/apache/flex/collections/FlattenedList.as
@@ -111,7 +111,7 @@ package org.apache.flex.collections
 		 */
 		public function isOpen(node:Object):Boolean
 		{
-			return openNodes.indexOf(node) != -1;
+			return openNodes.indexOf(node) !== -1;
 		}
 		
 		/**
@@ -146,7 +146,7 @@ package org.apache.flex.collections
 		public function closeNode(node:Object):void
 		{
 			var i:int = openNodes.indexOf(node);
-			if (i != -1) {
+			if (i !== -1) {
 				
 				if (hdata.hasChildren(node)) {
 					var children:Array = hdata.getChildren(node) as Array;
@@ -186,13 +186,16 @@ package org.apache.flex.collections
 		 */
 		private function godeep(seeking:Object, node:Object, depth:int):int
 		{
-			if (seeking == node) return depth;
+			if (seeking === node)
+				return depth;
 			
 			if (hdata.hasChildren(node)) {
 				var children:Array = hdata.getChildren(node) as Array;
-				for (var i:int=0; i < children.length; i++) {
-					var newDepth:int = godeep(seeking, children[i], depth+1)
-					if (newDepth > 0) return newDepth;
+				var length:int = children.length;
+				for (var i:int=0; i < length; i++) {
+					var newDepth:int = godeep(seeking, children[i], depth+1);
+					if (newDepth > 0)
+						return newDepth;
 				}
 			}