perf(node): removed unnecessary function calls to escapes
Description
I noticed the utils in the node package had two unnecessary function calls which could have been reduced to a single regexp. This will provide a small performance improvement which will be greater if called often.
What is the purpose of this pull request?
- [ ] Bug fix
- [ ] New Feature
- [ ] Documentation update
- [X] Other
I don't get it, my commit isn't related to that specific test in any way, even the package isn't involved at all. Is the build broken?
The CI issue is probably a flaky test, sorry about that. Thanks for the PR, do you have metrics about the perf improvement of this change? I think it may be a bit faster, but the added complexity doesn't justify the optimization. It would be better to find a way to avoid this hack in the future directly.
I'm sorry I have no benchmarks, just knowledge about the JS stack and an understanding of the added latency of calling multiple functions, and the fact a single regexp is faster than multiple ones of the same added complexity. If you think this adds too much mental overhead when looking at the code I can understand :) just wanted to be helpful:)
/node_modules/vite/bin/vite.js:2 import { performance } from 'node:perf_hooks' ^
SyntaxError: Unexpected token { at Module._compile (internal/modules/cjs/loader.js:723:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
I don't get the comment. Sorry.. it has nothing to do with my PR..
I also think this makes it hard to maintain even if it theoretically improves performance. If we do want to merge this, I think we need benchmarks to justify it.
I rely on your judgement, I have no way to provide a valid benchmark as it could vary based on many parameters.
I just applied common sense but as I said I can understand the added complexity you see could make it worthless.
Let's close this for now then. Thanks again @Cadienvan, and it isn't worthless. It is just that we need to keep complexity in check so we should only increase it when it will be for a proven win.