Commit 5791f372 authored by webchick's avatar webchick

#460448 follow-up by ridgerunner: Further optimize CSS aggregation regex.

parent da1a8593
......@@ -3543,7 +3543,7 @@ function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
// There are different conditions for removing leading and trailing
// whitespace.
// @see http://php.net/manual/en/regexp.reference.subpatterns.php
$contents = preg_replace_callback('<
$contents = preg_replace('<
# Strip leading and trailing whitespace.
\s*([@{};,])\s*
# Strip only leading whitespace from:
......@@ -3554,7 +3554,10 @@ function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
# - Colon: Retain :pseudo-selectors.
| ([\(:])\s+
>xS',
'_drupal_load_stylesheet_content',
// Only one of the three capturing groups will match, so its reference
// will contain the wanted value and the references for the
// two non-matching groups will be replaced with empty strings.
'$1$2$3',
$contents
);
// End the file with a new line.
......@@ -3568,16 +3571,6 @@ function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
return $contents;
}
/**
* Helper for drupal_load_stylesheet_content().
*/
function _drupal_load_stylesheet_content($matches) {
// Discard the full match.
unset($matches[0]);
// Use the non-empty match.
return current(array_filter($matches));
}
/**
* Loads stylesheets recursively and returns contents with corrected paths.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment