Hoist RegExp Literals in SourceMapDevToolPlugin
See original GitHub issueBug report
What is the current behavior? The use of RegExp literals create unnecessary object references/allocations especially in iterated hot paths like SourceMapDevToolPlugin. We should hoist these to the top of file and give them useful names so people understand what the heck they do.
If the current behavior is a bug, please provide the steps to reproduce. Some Examples:
Mapping over a RegExp literal: https://github.com/webpack/webpack/blob/3ad4fcac25a976277f2d9cceb37bc81602e96b13/lib/SourceMapDevToolPlugin.js#L419
Big Async ForEach Statement with multiple RexExp Literal statements: https://github.com/webpack/webpack/blob/3ad4fcac25a976277f2d9cceb37bc81602e96b13/lib/SourceMapDevToolPlugin.js#L384-L551
What is the expected behavior? Less memory allocation, less garbage collection triggered.
Happy to PR this. There are quite a few of these examples still lying around webpack that should be cleaned up but I’ll start with this.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
@markjm Here is an example of mem allocation hotpath if this helps. This tree is during the forEach calls referenced in the PR.
Issue was closed because of inactivity.
If you think this is still a valid issue, please file a new issue with additional information.