perf($parse) use a faster path when the number of path parts is low

Use a faster path when the number of path tokens is low (ie the common case).
This results in a better than 19x improvement in the time spent in $parse and
produces output that is about the same speed in chrome and substantially faster
in firefox.
http://jsperf.com/angularjs-parse-getter/6

Closes #5359
This commit is contained in:
Karl Seamon
2013-12-05 18:08:52 -05:00
committed by Igor Minar
parent f3a796e522
commit 864b2596b2
2 changed files with 44 additions and 17 deletions

View File

@@ -906,6 +906,7 @@ describe('parser', function() {
expect($parse('a.b')({a: {b: 0}}, {a: {b:1}})).toEqual(1);
expect($parse('a.b')({a: null}, {a: {b:1}})).toEqual(1);
expect($parse('a.b')({a: {b: 0}}, {a: null})).toEqual(undefined);
expect($parse('a.b.c')({a: null}, {a: {b: {c: 1}}})).toEqual(1);
}));
});