=== modified file 'includes/path.inc'
--- includes/path.inc	2006-11-17 05:15:19 +0000
+++ includes/path.inc	2006-11-18 11:15:06 +0000
@@ -24,7 +24,8 @@ function drupal_init_path() {
 
 /**
  * Given an alias, return its Drupal system URL if one exists. Given a Drupal
- * system URL return its alias if one exists.
+ * system URL return one of its aliases if such a one exists. Otherwise,
+ * return FALSE.
  *
  * @param $action
  *   One of the following values:
@@ -39,39 +40,44 @@ function drupal_init_path() {
  *   found.
  */
 function drupal_lookup_path($action, $path = '') {
-  static $map = array();
+  // $map keys are Drupal paths and the values are the corresponding aliases
+  static $map = array(), $no_src = array();
   static $count = NULL;
 
+  // Use $count to avoid looking up paths in subsequent calls if there simply are no aliases
   if ($count === NULL) {
     $count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}'));
   }
 
   if ($action == 'wipe') {
     $map = array();
+    $no_src = array();
   }
   elseif ($count > 0 && $path != '') {
     if ($action == 'alias') {
       if (isset($map[$path])) {
         return $map[$path];
       }
-      if ($alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path))) {
-        $map[$path] = $alias;
-        return $alias;
-      }
-      else {
-        $map[$path] = $path;
-      }
+      $alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path));
+      $map[$path] = $alias;
+      return $alias;
     }
-    elseif ($action == 'source') {
-      if ($alias = array_search($path, $map)) {
-        return $alias;
-      }
-      if (!isset($map[$path])) {
+    // Check $no_src for this $path in case we've already determined that there 
+    // isn't a path that has this alias
+    elseif ($action == 'source' && !isset($no_src[$path])) {
+      // Look for the value $path within the cached $map
+      if (!$src = array_search($path, $map)) {
         if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) {
           $map[$src] = $path;
-          return $src;
+        }
+        else {
+          // We can't 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. Thus cache to $no_src.
+          $no_src[$path] = TRUE;
         }
       }
+      return $src;
     }
   }
 

=== modified file 'modules/comment/comment.module'
--- modules/comment/comment.module	2006-11-12 00:11:15 +0000
+++ modules/comment/comment.module	2006-11-18 19:55:11 +0000
@@ -179,7 +179,15 @@ function comment_block($op = 'list', $de
 }
 
 function theme_comment_block() {
-  $result = db_query_range(db_rewrite_sql('SELECT c.nid, c.subject, c.cid, c.timestamp FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE n.status = 1 AND c.status = %d ORDER BY c.timestamp DESC', 'c'), COMMENT_PUBLISHED, 0, 10);
+  $result1 = db_query_range(db_rewrite_sql("SELECT n.nid from {node_comment_statistics} n WHERE n.comment_count > 0 ORDER BY n.last_comment_timestamp DESC"),0, 10);
+  
+  $recent_nids = array();
+  
+  while ($cnode = db_fetch_object($result1)) {
+    $recent_nids[] = $cnode->nid;
+  }
+  
+  $result = db_query_range('SELECT c.nid, c.subject, c.cid, c.timestamp FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE c.nid IN ('.implode(',',$recent_nids).') AND n.status = 1 AND c.status = %d ORDER BY c.timestamp DESC',COMMENT_PUBLISHED,0,10);
   $items = array();
   while ($comment = db_fetch_object($result)) {
     $items[] = l($comment->subject, 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid) .'<br />'. t('@time ago', array('@time' => format_interval(time() - $comment->timestamp)));

