typegoose / typegoose/mongodb-memory-server
Consider moving constant regexes to use constants
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.8k
- Forks
- 191
- Avg merge
- 4h 25m
- Merged PRs (30d)
- 10
Description
I have recently learned that regexes get re-created *1 every time they are executed, unless they are stored in a constant, so this could (at least slightly) improve performance by not having to re-compile the regexes everytime a line is checked, though i have not measured performance..
*1 apparently it is only compiled once but every time they are executed a new regexp object is created and needs to be gb collected
MDN Guide: Regular Expressions
also see this stackoverflow thread
probably should do some measurements just to be sure, but from my slight look it should be at least somewhat better for V8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files, tests, or entry points are named. Start by locating the repeated regular expressions in the TypeScript code and measure their behavior before and after storing them in constants. Done means the measurements support the change and the relevant regexes use constants without changing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100