Index: pathauto.inc
===================================================================
--- pathauto.inc	(.../trunk)	(revision 2032)
+++ pathauto.inc	(.../tags/6.x-1.x-dev-patched1)	(revision 2032)
@@ -438,6 +438,35 @@
 }
 
 /**
+ * The pathauto token pattern string is stored in a variable labeled with a naming convention. 
+ * The value of the variable should be obtained here by all accessing functions.
+ * @param $module
+ *   name of the module
+ * @param $type
+ *   name of type, e. g. content type
+ * @param $language
+ *   language abbreviation
+ * @return
+ *   pattern string, e. g. "/items/[nid]"
+ */
+function pathauto_get_pattern($module, $type = NULL, $language = '') {
+  if (!empty($type)) {
+    $pattern = trim(variable_get("pathauto_{$module}_{$type}_{$language}_pattern", ''));
+    if (empty($pattern)) {
+      $pattern = trim(variable_get("pathauto_{$module}_{$type}_pattern", ''));
+    }
+  }
+  if (empty($pattern)) {
+    $pattern = trim(variable_get("pathauto_{$module}_pattern", ''));
+  }
+  // No pattern? Do nothing (otherwise we may blow away existing aliases...)
+  if (empty($pattern)) {
+    return '';
+  }
+  return $pattern;
+}
+
+/**
  * Generalized function to get tokens across all Pathauto types.
  *
  * @param $object
@@ -447,8 +476,24 @@
  *   Pathauto expects to see them.
  */
 function pathauto_get_placeholders($type, $object) {
+	
   if (function_exists('token_get_values')) {
-    $full = token_get_values($type, $object, TRUE);
+
+  	//get the pathauto pattern first, to see which tokens are necessary.
+    $pattern = pathauto_get_pattern('node', $node->type, $node->language);
+    //Get the token keys/values. Actually, the additional argument $patterns limits the token-value
+    //building to the occuring tokens inside the pattern. This leads to significant performance 
+    //improvements especially on when using a large number of modules (and token lists/values). 
+    $full = token_get_values($type, $object, TRUE, array(), $pattern);
+
+  	//PATCH GN: List all tokens first and call only those token_values hooks
+    //which provide this token. It assumes that the hook token_list() is 
+    //implemented in the same module as the hook token_values() which should
+    //be the usual case. Otherwise it falls back to the brute-force approach
+    //iterating through all hooks
+    $pattern = pathauto_get_pattern('node', $node->type, $node->language);
+    $full = token_get_values($type, $object, TRUE, array(), $pattern);
+
     $tokens = token_prepare_tokens($full->tokens);
     $values = pathauto_clean_token_values($full);
     return array('tokens' => $tokens, 'values' => $values);
