mirror of
https://github.com/matthiasmullie/minify.git
synced 2025-02-21 15:22:48 +01:00
Simplify regex, we can assume whitespace has been stripped already
This commit is contained in:
parent
b48a6d34ff
commit
49061c0e06
@ -559,12 +559,12 @@ class CSS extends Minify
|
||||
// looped because there may be multiple 0s inside 1 group of parentheses
|
||||
do {
|
||||
$previous = $content;
|
||||
$content = preg_replace('/\(([^\(\)]+)\s+[\+\-]\s+0(\s+[^\(\)]+)?\)/', '(\\1\\2)', $content);
|
||||
$content = preg_replace('/\(([^\(\)]+) [\+\-] 0( [^\(\)]+)?\)/', '(\\1\\2)', $content);
|
||||
} while ($content !== $previous);
|
||||
// strip all `0 +` occurrences: calc(0 + 10%) -> calc(10%)
|
||||
$content = preg_replace('/\(\s*0\s+\+\s+([^\(\)]+)\)/', '(\\1)', $content);
|
||||
$content = preg_replace('/\(0 \+ ([^\(\)]+)\)/', '(\\1)', $content);
|
||||
// strip all `0 -` occurrences: calc(0 - 10%) -> calc(-10%)
|
||||
$content = preg_replace('/\(\s*0\s+\-\s+([^\(\)]+)\)/', '(-\\1)', $content);
|
||||
$content = preg_replace('/\(0 \- ([^\(\)]+)\)/', '(-\\1)', $content);
|
||||
// I'm not going to attempt to optimize away `x * 0` instances:
|
||||
// it's dumb enough code already that it likely won't occur, and it's
|
||||
// too complex to do right (order of operations would have to be
|
||||
|
Loading…
x
Reference in New Issue
Block a user