Commit e825e61
authored
Avoid per-key hash lookup when excluded_keys is empty (#318)
* Avoid per-key hash lookup when excluded_keys is empty
Store nil instead of an empty hash when no excluded_keys are configured
(the default) and use safe navigation (&.key?) in the hot loop. This
avoids an unnecessary hash lookup for every key at every level of the
statistics tree.
Benchmarked at ~39% faster for the default (empty) case with ~200 keys,
with no penalty when exclusions are configured.
* Skip hash construction when excluded_keys is empty
Avoid allocating and freezing an empty hash in the constructor when no
exclusions are configured, as suggested by Copilot review.1 parent d1ad337 commit e825e61
1 file changed
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
90 | | - | |
| 93 | + | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
| |||
0 commit comments