? patches
Index: pathauto.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/pathauto/pathauto.inc,v
retrieving revision 1.76
diff -u -p -r1.76 pathauto.inc
--- pathauto.inc	28 Jun 2010 19:31:58 -0000	1.76
+++ pathauto.inc	30 Jun 2010 19:05:30 -0000
@@ -139,26 +139,37 @@ function _pathauto_existing_alias_data($
 function pathauto_cleanstring($string, $clean_slash = TRUE) {
   $output = $string;
 
-  // Optionally transliterate (by running through the Transliteration module)
-  if (variable_get('pathauto_transliterate', FALSE)) {
-    if (module_exists('transliteration')) {
-      $output = transliteration_get($output);
-    }
-    else {
-      drupal_set_message(t('Pathauto could not transliterate the path, as the Transliteration module has been disabled.'), 'error');
+  // Statically cache the transliteration setting.
+  $transliterate = &drupal_static('pathauto_cleanstring:transliterate');
+  if (!isset($transliterate)) {
+    if ($transliterate = variable_get('pathauto_transliterate', FALSE)) {
+      if (!module_exists('transliteration')) {
+        $transliterate = FALSE;
+        drupal_set_message(t('Pathauto could not transliterate the path, as the Transliteration module has been disabled.'), 'error');
+      }
     }
   }
+  // Optionally transliterate (by running through the Transliteration module)
+  if ($transliterate) {
+    $output = transliteration_get($output);
+  }
 
-  // Replace or drop punctuation based on user settings
+  // Fetch and statically cache the punctuation replacements.
   $separator = variable_get('pathauto_separator', '-');
-  $punctuation = pathauto_punctuation_chars();
-  foreach ($punctuation as $name => $details) {
-    $action = variable_get('pathauto_punctuation_' . $name, PATHAUTO_PUNCTUATION_REMOVE);
-    if ($action != PATHAUTO_PUNCTUATION_DO_NOTHING) {
-      // Slightly tricky inline if which either replaces with the separator or nothing
-      $output = str_replace($details['value'], ($action ? $separator : ''), $output);
+  $punctuation = &drupal_static('pathauto_cleanstring:punctuation');
+  if (!isset($punctuation)) {
+    $punctuation = array();
+    foreach (pathauto_punctuation_chars() as $name => $details) {
+      $action = variable_get('pathauto_punctuation_' . $name, 0);
+      if ($action != PATHAUTO_PUNCTUATION_DO_NOTHING) {
+        $punctuation[$details['value']] = $action ? $separator : '';
+      }
     }
   }
+  // Replace or drop punctuation.
+  if (!empty($punctuation)) {
+    $output = str_replace(array_keys($punctuation), $punctuation, $output);
+  }
 
   // If something is already urlsafe then don't remove slashes
   if ($clean_slash) {
@@ -180,7 +191,6 @@ function pathauto_cleanstring($string, $
       $ignore_words_regex = '\b' . $ignore_words_regex . '\b';
     }
   }
-
   // Get rid of words that are on the ignore list
   if ($ignore_words_regex) {
     if (function_exists('mb_eregi_replace')) {
