Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

chore($parse): remove simpleGetter optimizations as they're no longer valid #8101

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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