Commit 1bf50ba
committed
Decrease string allocations in apply_inflections
In `apply_inflections` a string is down cased and some whitespace stripped in the front (which allocate strings). This would normally be fine, however `uncountables` is a fairly small array (10 elements out of the box) and this method gets called a TON. Instead we can keep an array of valid regexes for each uncountable so we don't have to allocate new strings.
This change buys us 325,106 bytes of memory and 3,251 fewer objects per request.1 parent f80aa59 commit 1bf50ba
File tree
2 files changed
+36
-5
lines changed- activesupport/lib/active_support/inflector
2 files changed
+36
-5
lines changedLines changed: 34 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
30 | 61 | | |
31 | 62 | | |
32 | 63 | | |
33 | 64 | | |
34 | 65 | | |
35 | 66 | | |
36 | 67 | | |
37 | | - | |
| 68 | + | |
38 | 69 | | |
39 | 70 | | |
40 | 71 | | |
| |||
160 | 191 | | |
161 | 192 | | |
162 | 193 | | |
163 | | - | |
| 194 | + | |
164 | 195 | | |
165 | 196 | | |
166 | 197 | | |
| |||
185 | 216 | | |
186 | 217 | | |
187 | 218 | | |
188 | | - | |
| 219 | + | |
189 | 220 | | |
190 | 221 | | |
191 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
| 375 | + | |
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| |||
0 commit comments