Commit f83bdbd
committed
Performance improvements to atrule() and trim() fns
Before this change, `atrule()` was a cascade of potentially failing RegExps.
This change introduces a short-circuit that bypasses the RegExps if the
next character is not an '@'. `make bench` shows a 20-25% improvement in
op/s.
Also before this change, when the argument is falsy `trim()` calls `replace()`
on the empty string. This change guards against unnecessary calls to `replace()`
with a ternary. `make bench` shows a 2.5-5.5% improvement in op/s.
With both changes, make bench shows a combined 30-40% improvement.
Benchmarks were run 5 times and the results averaged.1 parent eca598f commit f83bdbd
1 file changed
+3
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
| 453 | + | |
| 454 | + | |
453 | 455 | | |
454 | 456 | | |
455 | 457 | | |
| |||
487 | 489 | | |
488 | 490 | | |
489 | 491 | | |
490 | | - | |
| 492 | + | |
491 | 493 | | |
0 commit comments