 modules/taxonomy/taxonomy.module |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git modules/taxonomy/taxonomy.module modules/taxonomy/taxonomy.module
index f7f3e25..7708d52 100644
--- modules/taxonomy/taxonomy.module
+++ modules/taxonomy/taxonomy.module
@@ -749,7 +749,11 @@ 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__, array());
+  
+  if (empty($names)) {
+    $names = db_query('SELECT name, machine_name, vid FROM {taxonomy_vocabulary}')->fetchAllAssoc('machine_name');
+  }
   return $names;
 }
 
@@ -1028,6 +1032,14 @@ class TaxonomyVocabularyController extends DrupalDefaultEntityController {
     $query->orderBy('base.name');
     return $query;
   }
+  
+  /**
+   * Resets the internal, static entity cache.
+   */
+  public function resetCache() {
+    parent::resetCache();
+    drupal_static_reset('taxonomy_vocabulary_get_names');
+  }
 }
 
 /**
@@ -1098,8 +1110,12 @@ function taxonomy_vocabulary_load($vid) {
  *   Results are statically cached.
  */
 function taxonomy_vocabulary_machine_name_load($name) {
-  $vocabularies = taxonomy_vocabulary_load_multiple(NULL, array('machine_name' => $name));
-  return reset($vocabularies);
+  $names = taxonomy_vocabulary_get_names();
+  if (isset($names[$name])) {
+    // Convert $name to $vid in order to avoid automatic cache miss.
+    return taxonomy_vocabulary_load($names[$name]->vid);
+  }
+  return FALSE;
 }
 
 /**
