Skip to content

Commit

Permalink
chore($parse): remove simpleGetter optimizations as they're no longer…
Browse files Browse the repository at this point in the history
… valid

Closes angular#8101
  • Loading branch information
rodyhaddad committed Jul 10, 2014
1 parent 20b0c24 commit 5f6b378
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions src/ng/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,26 +875,6 @@ function cspSafeGetterFn(key0, key1, key2, key3, key4, fullExp) {
};
}

function simpleGetterFn1(key0, fullExp) {
ensureSafeMemberName(key0, fullExp);

return function simpleGetterFn1(scope, locals) {
if (scope == null) return undefined;
return ((locals && locals.hasOwnProperty(key0)) ? locals : scope)[key0];
};
}

function simpleGetterFn2(key0, key1, fullExp) {
ensureSafeMemberName(key0, fullExp);
ensureSafeMemberName(key1, fullExp);

return function simpleGetterFn2(scope, locals) {
if (scope == null) return undefined;
scope = ((locals && locals.hasOwnProperty(key0)) ? locals : scope)[key0];
return scope == null ? undefined : scope[key1];
};
}

function getterFn(path, options, fullExp) {
// Check whether the cache has this getter already.
// We can use hasOwnProperty directly on the cache because we ensure,
Expand All @@ -907,13 +887,8 @@ function getterFn(path, options, fullExp) {
pathKeysLength = pathKeys.length,
fn;

// When we have only 1 or 2 tokens, use optimized special case closures.
// http://jsperf.com/angularjs-parse-getter/6
if (pathKeysLength === 1) {
fn = simpleGetterFn1(pathKeys[0], fullExp);
} else if (pathKeysLength === 2) {
fn = simpleGetterFn2(pathKeys[0], pathKeys[1], fullExp);
} else if (options.csp) {
if (options.csp) {
if (pathKeysLength < 6) {
fn = cspSafeGetterFn(pathKeys[0], pathKeys[1], pathKeys[2], pathKeys[3], pathKeys[4], fullExp);
} else {
Expand Down

0 comments on commit 5f6b378

Please sign in to comment.