Performance: don't use VM when not needed #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As this package assumes `strings` in JS ${ is needed to do logic.
When it is not included, logic is not needed -> no vm needed.
Within my projects I have many templates which do not use execution but always take time. As they can be used often this should take as little time as possible.
In order to check I used this for loop:
With the optimisation I get this result:
time: 1.275ms
Without the optimisation I get
time: 3.614ms
While using this within telegraf-i18n this change alone improves the startup time of the bot (which recreates notifications in the users languages) from about 9s to 2.4s.
I also added the package.json files section and changed an Error to TypeError but as these changes are very small I don't think another PR is worth it.