Commit 47c093fb authored by webchick's avatar webchick

Issue #1620114 by Rob Loach, sun: Explicitly register \Drupal\Component and...

Issue #1620114 by Rob Loach, sun: Explicitly register \Drupal\Component and \Drupal\Core to increase class lookup performance.
parent cc108a13
......@@ -3125,6 +3125,15 @@ function drupal_classloader() {
break;
}
// Register explicit namespaces for Drupal core.
// The majority of namespaces that need to be resolved are from Drupal core,
// so registering/setting them before vendor libraries saves a few
// additional cycles per class lookup.
$loader->registerNamespaces(array(
'Drupal\Core' => DRUPAL_ROOT . '/core/lib',
'Drupal\Component' => DRUPAL_ROOT . '/core/lib',
));
// Register namespaces for vendor libraries managed by Composer.
$namespaces = require DRUPAL_ROOT . '/core/vendor/composer/autoload_namespaces.php';
$prefixes = array();
......@@ -3142,17 +3151,6 @@ function drupal_classloader() {
$loader->registerPrefixes($prefixes);
$loader->registerNamespaces($namespaces);
// Register the Drupal namespace for classes in core as a fallback.
// This allows to register additional namespaces within the Drupal namespace
// (e.g., for modules) and avoids an additional file_exists() on the Drupal
// core namespace, since the class loader can already determine the best
// namespace match based on a string comparison. It further allows modules
// to register/overload namespaces in Drupal core.
$loader->registerNamespaceFallbacks(array(
// All Drupal-namespaced code in core lives in /core/lib/Drupal.
'Drupal' => DRUPAL_ROOT . '/core/lib',
));
// Register the loader with PHP.
$loader->register();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment