Repository navigation
Commit 279528f
committed
uniq: cache locale check instead of querying env vars per line
is_c_locale() was called on every line inside key_end_index() when
-w/--check-chars is set, doing up to 3 std::env::var_os() lookups
each time. Locale env vars can't change mid-process, so this was
pure per-line overhead, causing uniq -w to be ~5x slower than GNU
uniq even for small -w values.
Compute is_c_locale() once at startup and cache it on the Uniq
struct instead.
Fixes #131991 parent 06f5f2b commit 279528f
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
205 | | - | |
| 206 | + | |
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
| |||
680 | 681 | | |
681 | 682 | | |
682 | 683 | | |
| 684 | + | |
683 | 685 | | |
684 | 686 | | |
685 | 687 | | |
| |||
0 commit comments