? drupal_lookup_path-HEAD.patch_1.txt
? path-rollback.patch
Index: includes/path.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/path.inc,v
retrieving revision 1.22
diff -u -p -r1.22 path.inc
--- includes/path.inc	14 Apr 2008 17:48:33 -0000	1.22
+++ includes/path.inc	16 Apr 2008 09:06:49 -0000
@@ -46,15 +46,20 @@ function drupal_init_path() {
 function drupal_lookup_path($action, $path = '', $path_language = '') {
   global $language;
   // $map is an array with language keys, holding arrays of Drupal paths to alias relations
-  static $map = array(), $no_src = array();
+  static $map = array(), $no_src = array(), $count;
 
   $path_language = $path_language ? $path_language : $language->language;
 
+  // Use $count to avoid looking up paths in subsequent calls if there simply are no aliases
+  if (!isset($count)) {
+    $count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}'));
+  }
+
   if ($action == 'wipe') {
     $map = array();
     $no_src = array();
   }
-  elseif (module_exists('path') && $path != '') {
+  elseif ($count > 0 && $path != '') {
     if ($action == 'alias') {
       if (isset($map[$path_language][$path])) {
         return $map[$path_language][$path];
