Commit 934ba4b
Hoist regex patterns to module-level in StyleSheet processors
Summary:
changelog: [internal]
Hoist inline regex patterns to module-level constants in processFilter.js, processBackgroundImage.js, and processTransformOrigin.js to avoid repeated regex compilation on each function call.
Fantom benchmark results (p50 latency, optimized build).
| Benchmark | Before | After | Improvement |
|---|---|---|---|
| 100 views with filter strings | 4.427ms | 3.556ms | 24.48% faster |
| 500 views with filter strings | 22.523ms | 17.861ms | 26.10% faster |
| 100 views with boxShadow strings | 5.835ms | 5.729ms | 1.85% faster |
| 500 views with boxShadow strings | 29.914ms | 28.846ms | 3.70% faster |
| 100 views with transformOrigin strings | 2.521ms | 2.512ms | 0.36% faster |
| 500 views with transformOrigin strings | 12.706ms | 12.421ms | 2.30% faster |
Reviewed By: javache
Differential Revision: D958530701 parent d527f2d commit 934ba4b
3 files changed
Lines changed: 45 additions & 20 deletions
File tree
- packages/react-native/Libraries/StyleSheet
Lines changed: 19 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
23 | 31 | | |
24 | 32 | | |
25 | 33 | | |
| |||
81 | 89 | | |
82 | 90 | | |
83 | 91 | | |
84 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
85 | 95 | | |
86 | 96 | | |
87 | 97 | | |
| |||
255 | 265 | | |
256 | 266 | | |
257 | 267 | | |
258 | | - | |
259 | | - | |
260 | | - | |
| 268 | + | |
261 | 269 | | |
262 | 270 | | |
263 | 271 | | |
| |||
281 | 289 | | |
282 | 290 | | |
283 | 291 | | |
284 | | - | |
| 292 | + | |
285 | 293 | | |
286 | 294 | | |
287 | 295 | | |
288 | 296 | | |
289 | 297 | | |
290 | 298 | | |
291 | 299 | | |
292 | | - | |
| 300 | + | |
293 | 301 | | |
294 | 302 | | |
295 | 303 | | |
| |||
626 | 634 | | |
627 | 635 | | |
628 | 636 | | |
629 | | - | |
| 637 | + | |
630 | 638 | | |
631 | 639 | | |
632 | 640 | | |
633 | 641 | | |
634 | 642 | | |
635 | | - | |
| 643 | + | |
636 | 644 | | |
637 | 645 | | |
638 | 646 | | |
| |||
726 | 734 | | |
727 | 735 | | |
728 | 736 | | |
729 | | - | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
730 | 740 | | |
731 | 741 | | |
732 | 742 | | |
| |||
Lines changed: 16 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
18 | 26 | | |
19 | 27 | | |
20 | 28 | | |
| |||
43 | 51 | | |
44 | 52 | | |
45 | 53 | | |
46 | | - | |
| 54 | + | |
47 | 55 | | |
48 | 56 | | |
49 | | - | |
| 57 | + | |
50 | 58 | | |
51 | 59 | | |
52 | | - | |
| 60 | + | |
53 | 61 | | |
54 | 62 | | |
55 | 63 | | |
| |||
120 | 128 | | |
121 | 129 | | |
122 | 130 | | |
123 | | - | |
124 | | - | |
| 131 | + | |
| 132 | + | |
125 | 133 | | |
126 | 134 | | |
127 | 135 | | |
| |||
258 | 266 | | |
259 | 267 | | |
260 | 268 | | |
261 | | - | |
| 269 | + | |
262 | 270 | | |
263 | 271 | | |
264 | 272 | | |
| |||
305 | 313 | | |
306 | 314 | | |
307 | 315 | | |
308 | | - | |
309 | | - | |
| 316 | + | |
| 317 | + | |
310 | 318 | | |
311 | 319 | | |
312 | 320 | | |
| |||
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
20 | 23 | | |
21 | 24 | | |
22 | 25 | | |
23 | | - | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
28 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
29 | 34 | | |
30 | 35 | | |
31 | 36 | | |
| |||
53 | 58 | | |
54 | 59 | | |
55 | 60 | | |
56 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
57 | 64 | | |
58 | 65 | | |
59 | 66 | | |
| |||
0 commit comments