chore($parse): convert parser() and lex() to prototype-based code

This reduces memory consumption of parsed angular expressions and
speeds up parsing.

This JSPerf case demonstrates the performance boost:
http://jsperf.com/closure-vs-prototype-ngparser

Chrome: 1.5–2x boost
FF: slightly slower (I would love to know why)
IE: 4x boost

To be clear, this doesn't have any impact on runtime performance
of expressions as demostrated in this JSPerf:
http://jsperf.com/angular-parser-changes

Closes #3681
This commit is contained in:
jankuca 2013-08-20 17:19:49 -07:00 committed by Igor Minar
parent 948e8ca325
commit 49e06eace5
2 changed files with 500 additions and 429 deletions

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,15 @@
describe('parser', function() {
describe('lexer', function() {
var lex;
beforeEach(function () {
lex = function () {
var lexer = new Lexer();
return lexer.lex.apply(lexer, arguments);
};
});
it('should tokenize a string', function() {
var tokens = lex("a.bc[22]+1.3|f:'a\\\'c':\"d\\\"e\"");
var i = 0;