From 5791f3724b0a395bc21f03b2cdf860fbc2b41a79 Mon Sep 17 00:00:00 2001 From: Angie Byron <webchick@24967.no-reply.drupal.org> Date: Fri, 14 Jan 2011 08:37:20 +0000 Subject: [PATCH] #460448 follow-up by ridgerunner: Further optimize CSS aggregation regex. --- includes/common.inc | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/includes/common.inc b/includes/common.inc index 28377d71a34d..62a5037f01a3 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -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. * -- GitLab