=== modified file 'includes/path.inc'
--- includes/path.inc	2006-11-17 05:15:19 +0000
+++ includes/path.inc	2006-11-18 08:42:38 +0000
@@ -39,7 +39,8 @@ function drupal_init_path() {
  *   found.
  */
 function drupal_lookup_path($action, $path = '') {
-  static $map = array();
+  // $map keys are Drupal paths and the value is the corresponding alias
+  static $map = array(), $no_src = array();
   static $count = NULL;
 
   if ($count === NULL) {
@@ -48,6 +49,7 @@ function drupal_lookup_path($action, $pa
 
   if ($action == 'wipe') {
     $map = array();
+    $no_src = array();
   }
   elseif ($count > 0 && $path != '') {
     if ($action == 'alias') {
@@ -62,15 +64,21 @@ function drupal_lookup_path($action, $pa
         $map[$path] = $path;
       }
     }
-    elseif ($action == 'source') {
+    // First we check whether we know already there is no path with this alias.
+    elseif ($action == 'source' && !isset($no_src[$path])) {
+      // Then we check whether there is only a path which has this alias.
       if ($alias = array_search($path, $map)) {
         return $alias;
       }
-      if (!isset($map[$path])) {
-        if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) {
-          $map[$src] = $path;
-          return $src;
-        }
+      if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) {
+        $map[$src] = $path;
+        return $map[$src];
+      }
+      else {
+        // We can not record anything into $map because we do not have a valid
+        // index and there is no need because we have not learned anything
+        // about any Drupal path.
+        $no_src[$path] = TRUE;
       }
     }
   }

