You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arrays in JavaScript are by definition sparse, so using a Map with number key seems like a potential performance improvement. For example, DFAState.edges is high-traffic, particularly in getTarget().
A quick trial experiment of this showed around 17% speed improvement in TestLexerSeed. Before the change:
lex_legacy_java_utf8 average time 2951us over 2000 runs of 29600 symbols
lex_legacy_java_utf8 average time 7137us over 2000 runs of 29600 symbols DFA cleared
lex_new_java_utf8 average time 2937us over 2000 runs of 29600 symbols
lex_new_java_utf8 average time 7180us over 2000 runs of 29600 symbols DFA cleared
With Array replacing Map<number, DFAState> the results were:
lex_legacy_java_utf8 average time 2436us over 2000 runs of 29600 symbols
lex_legacy_java_utf8 average time 6733us over 2000 runs of 29600 symbols DFA cleared
lex_new_java_utf8 average time 2481us over 2000 runs of 29600 symbols
lex_new_java_utf8 average time 6761us over 2000 runs of 29600 symbols DFA cleared
The text was updated successfully, but these errors were encountered:
One challenge to this is that Array<T>.keys returns number keys with undefined elements. This required a little filtering in a toString() method, but Array.forEach() works out well.
Other potential applications of this include ATN.LL1Table, which might be significant in parsing speed.
TokenStreamRewriter.ts indexToOp, ATNDeserialization rulePrecedenceDecisions, and ParserATNSimulator.ts statesFromAlt1 also seem to fit the pattern, but seem not to be on critical paths.
Arrays in JavaScript are by definition sparse, so using a Map with number key seems like a potential performance improvement. For example,
DFAState.edges
is high-traffic, particularly ingetTarget()
.A quick trial experiment of this showed around 17% speed improvement in TestLexerSeed. Before the change:
With Array replacing Map<number, DFAState> the results were:
The text was updated successfully, but these errors were encountered: