mirror of https://github.com/lukechilds/rollup.git
Browse Source
Most javascript engines do a lazy parsing optimization. For example if they see:
function X() {...}
They won't parse the contents of X until it is executed. However they often have to read the contents of X so that they can see if X uses any variables from the outer scope. Thus X ends up getting parsed twice.
Realizing that often one immediately executes a function, browser have optimized statements of the form:
(function X() {...})()
So that X is not parsed lazily. Traditionally this optimization looks for an open paren before the function. For example, here's the optimization in v8:
203391bcc0/src/parsing/parser.cc (L4256)
Since the factory is immediately executed (at least in the commonJS and global export case), this change avoids the double parsing that comes with parsing the function lazily.
rollup-init
bmaurer
9 years ago
committed by
GitHub
1 changed files with 2 additions and 2 deletions
Loading…
Reference in new issue