Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.577
diff -u -p -r1.577 taxonomy.module
--- modules/taxonomy/taxonomy.module	11 Feb 2010 17:44:47 -0000	1.577
+++ modules/taxonomy/taxonomy.module	2 Mar 2010 15:26:22 -0000
@@ -378,6 +378,7 @@ function taxonomy_vocabulary_save($vocab
   }
 
   cache_clear_all();
+  taxonomy_vocabulary_get_names_reset();
   entity_get_controller('taxonomy_vocabulary')->resetCache();
 
   return $status;
@@ -406,6 +407,7 @@ function taxonomy_vocabulary_delete($vid
   module_invoke_all('taxonomy', 'delete', 'vocabulary', $vocabulary);
 
   cache_clear_all();
+  taxonomy_vocabulary_get_names_reset();
   entity_get_controller('taxonomy_vocabulary')->resetCache();
 
   return SAVED_DELETED;
@@ -680,11 +682,28 @@ function taxonomy_get_vocabularies() {
  *   An array of vocabulary ids, names, machine names, keyed by machine name.
  */
 function taxonomy_vocabulary_get_names() {
-  $names = db_query('SELECT name, machine_name, vid FROM {taxonomy_vocabulary}')->fetchAllAssoc('machine_name');
+  $names = &drupal_static(__FUNCTION__);
+  if (!isset($names)) {
+    if ($cached = cache_get('taxonomy_vocabulary_get_names')) {
+      $names = $cached->data;
+    }
+    else {
+      $names = db_query('SELECT name, machine_name, vid FROM {taxonomy_vocabulary}')->fetchAllAssoc('machine_name');
+      cache_set('taxonomy_vocabulary_get_names', $names);
+    }
+  }
   return $names;
 }
 
 /**
+ * Clear the taxonomy_vocabulary_get_names() cache.
+ */
+function taxonomy_vocabulary_get_names_reset() {
+  drupal_static_reset('taxonomy_vocabulary_get_names');
+  cache_clear_all('taxonomy_vocabulary_get_names', 'cache');
+}
+
+/**
  * Find all parents of a given term ID.
  */
 function taxonomy_get_parents($tid, $key = 'tid') {
