summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-11-01 14:08:17 +0000
committerDries Buytaert <dries@buytaert.net>2009-11-01 14:08:17 +0000
commit54db3af335d51e3a976dccb8d0838ac9f83b752b (patch)
treeb06e2852b48fa2b7e623ac59bb647100d120c0ad
parent342ebd7776df44eae48876a2526949fef4d04d4b (diff)
downloadbrdo-54db3af335d51e3a976dccb8d0838ac9f83b752b.tar.gz
brdo-54db3af335d51e3a976dccb8d0838ac9f83b752b.tar.bz2
- Patch #619566 by sun: performance improvement: don't invoke hook_url_outbound_alter() if there's nothing to invoke.
-rw-r--r--includes/common.inc11
1 files changed, 10 insertions, 1 deletions
diff --git a/includes/common.inc b/includes/common.inc
index c23ed64d5..c6686ee01 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -2370,6 +2370,8 @@ function _format_date_callback(array $matches = NULL, $new_langcode = NULL) {
* alternative than url().
*/
function url($path = NULL, array $options = array()) {
+ static $url_outbound;
+
// Merge in defaults.
$options += array(
'fragment' => '',
@@ -2392,7 +2394,14 @@ function url($path = NULL, array $options = array()) {
$original_path = $path;
// Allow other modules to alter the outbound URL and options.
- drupal_alter('url_outbound', $path, $options, $original_path);
+ // Since PHP code cannot be unloaded, we statically cache the implementations
+ // of hook_url_outbound_alter() and only invoke them in case there are any.
+ if (!isset($url_outbound)) {
+ $url_outbound = (bool) module_implements('url_outbound_alter');
+ }
+ if ($url_outbound) {
+ drupal_alter('url_outbound', $path, $options, $original_path);
+ }
if ($options['fragment']) {
$options['fragment'] = '#' . $options['fragment'];