Commit e3c9bc1
committed
perf(env): optimize case-insensitive lookup with length fast path
Add findCaseInsensitiveKey helper that checks string length before
calling toUpperCase(), reducing unnecessary string operations.
DRY improvements:
- Extract duplicate case-insensitive search logic into helper
- Reuse helper in both get() and has() Proxy handlers
Performance impact:
- Fast path: O(1) length check eliminates mismatched keys immediately
- Only calls toUpperCase() when lengths match (rare case)
- Reduces overhead for common lookups with many env vars1 parent b135a1a commit e3c9bc1
1 file changed
Lines changed: 30 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
57 | 77 | | |
58 | 78 | | |
59 | 79 | | |
| |||
132 | 152 | | |
133 | 153 | | |
134 | 154 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
139 | 158 | | |
140 | 159 | | |
141 | 160 | | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
146 | 164 | | |
147 | 165 | | |
148 | 166 | | |
| |||
192 | 210 | | |
193 | 211 | | |
194 | 212 | | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
| 213 | + | |
| 214 | + | |
201 | 215 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
| 216 | + | |
| 217 | + | |
206 | 218 | | |
207 | 219 | | |
208 | 220 | | |
| |||
0 commit comments