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

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

Closed
wants to merge 1 commit into from

Conversation

jankuca
Copy link
Contributor

@jankuca jankuca commented Aug 21, 2013

I refactored most of the $parse code into prototypes for performance. The improvement is in extracting all the helper functions from parser() and lex() so that only one set of these is in use rather than a new one being created on each run. State is now shared via this.

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

@mhevery
Copy link
Contributor

mhevery commented Aug 23, 2013

What is the reason for this change? The resulting code will not minify as well and there is minimal impact to performance since expression get cached, so the cost of expression parsing is not that significant. I would like to see what impact this has on minified code.

@IgorMinar
Copy link
Contributor

it adds 45 bytes after gzip == insignificant

@ghost ghost assigned IgorMinar Oct 2, 2013
@jankuca jankuca closed this in 49e06ea Oct 4, 2013
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this pull request Jan 27, 2014
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 angular#3681
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this pull request Jan 27, 2014
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 angular#3681
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants