-
-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(linter): make all rules share a diagnostics vec
What This PR Does Each time a lint rule is run on a file, it will now store diagnostics in a shared vec instead of having its own list. This is done by moving `diagnostics` from `LintContext` to `ContextHost`. The motivating line of code can be found in `Linter::run` in `oxc_linter/src/lib.rs#145` ```rust rules.into_iter().flat_map(|(_, ctx)| ctx.into_message()).collect::<Vec<_>>() ``` Each `LintContext` allocates a new vec, and pushes diagnostics into it. After all run-related methods have been run, a new vec is created and those diagnostics are copied into it. This is `O(n+1)` allocations and `O(n)` copies, not to mention that allocations for the original vecs cannot be re-used since those vecs aren't dropped until after the new one is created.
- Loading branch information
Showing
3 changed files
with
35 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters