Index: includes/install.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/install.inc,v
retrieving revision 1.96
diff -u -p -r1.96 install.inc
--- includes/install.inc	15 Jul 2009 02:08:41 -0000	1.96
+++ includes/install.inc	17 Jul 2009 14:44:51 -0000
@@ -92,24 +92,23 @@ function drupal_load_updates() {
  *   Otherwise, FALSE.
  */
 function drupal_get_schema_versions($module) {
+  $updates = &drupal_static(__FUNCTION__, NULL);
+  if (!isset($updates)) {
   $updates = array();
   $functions = get_defined_functions();
-  foreach ($functions['user'] as $function) {
-    if (strpos($function, $module . '_update_') === 0) {
-      $version = substr($function, strlen($module . '_update_'));
-      if (is_numeric($version)) {
-        $updates[] = $version;
-      }
+  $functions = $functions['user'];
+  $regexp = '/(' . implode('|', module_list()) . ')_update_(\d+)/';
+  foreach ($functions as $function) {
+    if (preg_match($regexp, $function, $matches)) {
+      list(, $module, $number) = $matches;
+      $updates[$module][] = $number;
     }
   }
-  if (count($updates) == 0) {
-    return FALSE;
+  foreach ($updates as &$module_updates) {
+    sort($module_updates, SORT_NUMERIC);
   }
-
-  // Make sure updates are run in numeric order, not in definition order.
-  sort($updates, SORT_NUMERIC);
-
-  return $updates;
+}
+  return isset($updates[$module]) ? $updates[$module] : FALSE;
 }
 
 /**
