Skip to content

Commit 7f45021

Browse files
thiemowmdeKrinkle
authored andcommitted
Optimize border-radius flip by using native 'strlen' callback
Before: * input.css iterations=10000 max=2.99ms mean=0.09ms rate=10627/s * input.css iterations=10000 max=2.88ms mean=0.09ms rate=10565/s After: * input.css iterations=10000 max=2.89ms mean=0.07ms rate=13890/s * input.css iterations=10000 max=3.45ms mean=0.07ms rate=13915/s Based on the bench.php option from If86b1806e6f, using PHP 8.1, and input of: ``` .foo { border-radius: 2px 1px 3px; border-radius: 2px 0 0 2px; border-radius: 0 2px 2px 0; border-radius: 0; border-radius: 50% 1em; } ``` Change-Id: I712be1c4b3dd720d250ba32ba2534fdf8874fda1
1 parent 295ac1a commit 7f45021

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/CSSJanus.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,8 @@ private static function fixBorderRadius($css) {
322322
*/
323323
private static function calculateBorderRadius($matches) {
324324
$pre = $matches[1];
325-
$firstGroup = array_filter(array_slice($matches, 2, 4), function ($match) {
326-
return $match !== '';
327-
});
328-
$secondGroup = array_filter(array_slice($matches, 6, 4), function ($match) {
329-
return $match !== '';
330-
});
325+
$firstGroup = array_filter(array_slice($matches, 2, 4), 'strlen');
326+
$secondGroup = array_filter(array_slice($matches, 6, 4), 'strlen');
331327
$post = $matches[10] ?: '';
332328

333329
if ($secondGroup) {

0 commit comments

Comments
 (0)