diff --git a/includes/install.inc b/includes/install.inc
index 2ee29ba..866143c 100644
--- a/includes/install.inc
+++ b/includes/install.inc
@@ -38,17 +38,25 @@ function drupal_load_updates() {
  *   Otherwise, FALSE.
  */
 function drupal_get_schema_versions($module) {
+  static $functions = NULL;
+
+  if (!isset($functions)) {
+    $defined_functions = get_defined_functions();
+    $functions = preg_grep('/_update_/', $defined_functions['user']);
+  }
+
+  $target = $module .'_update_';
+  $offset = strlen($target);
   $updates = array();
-  $functions = get_defined_functions();
-  foreach ($functions['user'] as $function) {
-    if (strpos($function, $module .'_update_') === 0) {
-      $version = substr($function, strlen($module .'_update_'));
+  foreach ($functions as $function) {
+    if (strpos($function, $target) === 0) {
+      $version = substr($function, $offset);
       if (is_numeric($version)) {
         $updates[] = $version;
       }
     }
   }
-  if (count($updates) == 0) {
+  if (empty($updates)) {
     return FALSE;
   }
   sort($updates, SORT_NUMERIC);
