This is an automated email from the ASF dual-hosted git repository.
harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 09d4129 Language.is needs a bit of work
09d4129 is described below
commit 09d41292bf6391f46345485d031461ff29478fcf
Author: Harbs <[email protected]>
AuthorDate: Fri Mar 30 13:24:30 2018 +0300
Language.is needs a bit of work
---
.../royale/org/apache/royale/utils/Language.as | 23 ++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git
a/frameworks/projects/Language/src/main/royale/org/apache/royale/utils/Language.as
b/frameworks/projects/Language/src/main/royale/org/apache/royale/utils/Language.as
index 7534683..2ba7f5a 100644
---
a/frameworks/projects/Language/src/main/royale/org/apache/royale/utils/Language.as
+++
b/frameworks/projects/Language/src/main/royale/org/apache/royale/utils/Language.as
@@ -135,15 +135,24 @@ package org.apache.royale.utils
return true;
if (rightOperand === Object)
return true; // every value is an Object in ActionScript
except null and undefined (caught above)
-
- if (typeof leftOperand === 'string')
+ // A little faster to only call typeof once
+ var theType:String = typeof leftOperand;
+ //TODO This is actually incorrect for 'constructed'
strings
+ // The correct way is using
Object.prototype.toString.call(leftOperand) == '[object String]'
+ // But this is about 50 times slower than typeof
+ // "is String" should probably be pulled out into a
separate function
+ // which is called directly by the compiler to deal
with it in the most performant manner.
+ // Another (possibly better) option would be to have
the compiler throw an error
+ // if new is used with String, Number or Boolean. If
'new' is not allowed, the typeof check is enough.
+ if (theType === 'string')
return rightOperand === String;
- if (typeof leftOperand === 'number')
+ if (theType === 'number')
return rightOperand === Number;
- if (typeof leftOperand === 'boolean')
+ if (theType === 'boolean')
return rightOperand === Boolean;
+ //TODO add optimization to compiler to convert 'is
Array' directly to Array.isArray
if (rightOperand === Array)
return Array.isArray(leftOperand);
@@ -158,8 +167,7 @@ package org.apache.royale.utils
}
}
- superClass = leftOperand.constructor;
- superClass = superClass.superClass_;
+ superClass = leftOperand.constructor.superClass_;
if (superClass)
{
@@ -172,8 +180,7 @@ package org.apache.royale.utils
return true;
}
}
- superClass = superClass.constructor;
- superClass = superClass.superClass_;
+ superClass =
superClass.constructor.superClass_;
}
}
--
To stop receiving notification emails like this one, please contact
[email protected].