-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid allocating on every input line.
By using `BufRead::read_line` instead of `BufRead::lines`. Now allocations are only required (a) for the first occurrence of a particular line, and (b) for lines that are modified by `-e`. This requires some changes to handle cases where the line is a `&str` vs a `String` (e.g. after modification due to `-e`). This roughly doubles the speed of `counts` on files where every line is the same, and leaves it unchanged on files where every line is different. Typical cases will be between those two extremes. This idea came from @Shnatsel via nnethercote/perf-book#68.
- Loading branch information
1 parent
af5ea94
commit 7d39bbb
Showing
2 changed files
with
59 additions
and
27 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