@@ -80,7 +80,7 @@ function ensureSafeFunction(obj, fullExpression) {
80
80
}
81
81
}
82
82
83
- var OPERATORS = {
83
+ var OPERATORS = extend ( createMap ( ) , {
84
84
/* jshint bitwise : false */
85
85
'null' :function ( ) { return null ; } ,
86
86
'true' :function ( ) { return true ; } ,
@@ -118,7 +118,7 @@ var OPERATORS = {
118
118
// '|':function(self, locals, a,b){return a|b;},
119
119
'|' :function ( self , locals , a , b ) { return b ( self , locals ) ( self , locals , a ( self , locals ) ) ; } ,
120
120
'!' :function ( self , locals , a ) { return ! a ( self , locals ) ; }
121
- } ;
121
+ } ) ;
122
122
/* jshint bitwise: true */
123
123
var ESCAPE = { "n" :"\n" , "f" :"\f" , "r" :"\r" , "t" :"\t" , "v" :"\v" , "'" :"'" , '"' :'"' } ;
124
124
@@ -301,9 +301,10 @@ Lexer.prototype = {
301
301
text : ident
302
302
} ;
303
303
304
- // OPERATORS is our own object so we don't need to use special hasOwnPropertyFn
305
- if ( OPERATORS . hasOwnProperty ( ident ) ) {
306
- token . fn = OPERATORS [ ident ] ;
304
+ var fn = OPERATORS [ ident ] ;
305
+
306
+ if ( fn ) {
307
+ token . fn = fn ;
307
308
token . constant = true ;
308
309
} else {
309
310
var getter = getterFn ( ident , this . options , this . text ) ;
@@ -834,7 +835,7 @@ function setter(obj, path, setValue, fullExp) {
834
835
return setValue ;
835
836
}
836
837
837
- var getterFnCache = { } ;
838
+ var getterFnCache = createMap ( ) ;
838
839
839
840
/**
840
841
* Implementation of the "Black Hole" variant from:
@@ -875,16 +876,12 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4, fullExp) {
875
876
}
876
877
877
878
function getterFn ( path , options , fullExp ) {
878
- // Check whether the cache has this getter already.
879
- // We can use hasOwnProperty directly on the cache because we ensure,
880
- // see below, that the cache never stores a path called 'hasOwnProperty'
881
- if ( getterFnCache . hasOwnProperty ( path ) ) {
882
- return getterFnCache [ path ] ;
883
- }
879
+ var fn = getterFnCache [ path ] ;
880
+
881
+ if ( fn ) return fn ;
884
882
885
883
var pathKeys = path . split ( '.' ) ,
886
- pathKeysLength = pathKeys . length ,
887
- fn ;
884
+ pathKeysLength = pathKeys . length ;
888
885
889
886
// http://jsperf.com/angularjs-parse-getter/6
890
887
if ( options . csp ) {
@@ -923,11 +920,7 @@ function getterFn(path, options, fullExp) {
923
920
fn = evaledFnGetter ;
924
921
}
925
922
926
- // Only cache the value if it's not going to mess up the cache object
927
- // This is more performant that using Object.prototype.hasOwnProperty.call
928
- if ( path !== 'hasOwnProperty' ) {
929
- getterFnCache [ path ] = fn ;
930
- }
923
+ getterFnCache [ path ] = fn ;
931
924
return fn ;
932
925
}
933
926
@@ -984,7 +977,7 @@ function getterFn(path, options, fullExp) {
984
977
* service.
985
978
*/
986
979
function $ParseProvider ( ) {
987
- var cache = { } ;
980
+ var cache = createMap ( ) ;
988
981
989
982
var $parseOptions = {
990
983
csp : false
@@ -1001,9 +994,9 @@ function $ParseProvider() {
1001
994
case 'string' :
1002
995
cacheKey = exp = exp . trim ( ) ;
1003
996
1004
- if ( cache . hasOwnProperty ( cacheKey ) ) {
1005
- parsedExpression = cache [ cacheKey ] ;
1006
- } else {
997
+ parsedExpression = cache [ cacheKey ] ;
998
+
999
+ if ( ! parsedExpression ) {
1007
1000
if ( exp . charAt ( 0 ) === ':' && exp . charAt ( 1 ) === ':' ) {
1008
1001
oneTime = true ;
1009
1002
exp = exp . substring ( 2 ) ;
@@ -1020,11 +1013,7 @@ function $ParseProvider() {
1020
1013
oneTimeLiteralWatch : oneTimeWatch ;
1021
1014
}
1022
1015
1023
- if ( cacheKey !== 'hasOwnProperty' ) {
1024
- // Only cache the value if it's not going to mess up the cache object
1025
- // This is more performant that using Object.prototype.hasOwnProperty.call
1026
- cache [ cacheKey ] = parsedExpression ;
1027
- }
1016
+ cache [ cacheKey ] = parsedExpression ;
1028
1017
}
1029
1018
return addInterceptor ( parsedExpression , interceptorFn ) ;
1030
1019
0 commit comments