Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about performance #50

Open
missinglink opened this issue Nov 2, 2021 · 2 comments · May be fixed by #54
Open

question about performance #50

missinglink opened this issue Nov 2, 2021 · 2 comments · May be fixed by #54

Comments

@missinglink
Copy link

hi, is it strictly required to call charRegex() within every invocation?
wouldn't it make sense to call charRegex() once and save it in the module scope?

@sallar
Copy link
Owner

sallar commented Nov 2, 2021

@missinglink the functions are not chain-able or part of a class.. so there's no scope. it's important for FP purposes that each function is completely isolated of others

@missinglink
Copy link
Author

I see what you mean, from a FP point of view its not ideal to have a function depend on state external to the scope of the function itself.

However I'm not sure what you mean by 'there's no scope', there is always a scope and in this case it would be a 'module scope' rather than a 'function scope' or 'global scope'?

My understanding is that bundlers will all recognise this dependency and handle it appropriately.

It seems to me that the performance advantage of not instantiating this very large regexp on every invocation outweights the dependency.

@Richienb Richienb linked a pull request Jul 18, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants