cdiggins / myna-parser

Myna Parsing Library
https://cdiggins.github.io/myna-parser
MIT License
78 stars 15 forks source link

Possible performance improvements #13

Closed bd82 closed 7 years ago

bd82 commented 7 years ago

Class instances avoidance

I see much usage of the newkeyword.

I am uncertain but it appears as though it may also be used in hot spots( parser runtime) in the code and not only in one time initial definitions?

if that is indeed the case I suggest you try avoiding initializing class instances at parser runtime. Plain objects ({}) if sufficient would be much faster.

Specific boolean conditions.

This is a minor thing but conditions such as:

            if (!this.createsAstNode)

Will take longer than a more precise condition:

if (this.createsAstNode === false)

If these kind of conditions appear in enough hot spots in the code base you may be able to squeeze a a tiny bit of extra performance.

cdiggins commented 7 years ago

image

bd82 commented 7 years ago

Was this run on Chrome? If so which version?

I see a slightly different ordering on latest stable chrome 59