Skip to content
Snippets Groups Projects
Commit 0f845306 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#151868 by chx: avoid using array_shift() because it takes a lot of time to...

#151868 by chx: avoid using array_shift() because it takes a lot of time to rehash the array, so indexing the array is more performant, then shifting items one by one
parent 1a66aeb3
No related branches found
No related tags found
No related merge requests found
......@@ -330,7 +330,7 @@ function conf_init() {
$cookie_domain = substr($cookie_domain, 4);
}
$cookie_domain = explode(':', $cookie_domain);
$cookie_domain = '.'. array_shift($cookie_domain);
$cookie_domain = '.'. $cookie_domain[0];
// Per RFC 2109, cookie domains must contain at least one dot other than the
// first. For hosts such as 'localhost' or IP Addresses we don't set a cookie domain.
if (count(explode('.', $cookie_domain)) > 2 && !is_numeric(str_replace('.', '', $cookie_domain))) {
......@@ -868,15 +868,18 @@ function drupal_anonymous_user($session = '') {
* DRUPAL_BOOTSTRAP_FULL: Drupal is fully loaded, validate and fix input data.
*/
function drupal_bootstrap($phase) {
static $phases = array(DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_ACCESS, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE, DRUPAL_BOOTSTRAP_LANGUAGE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL);
static $phases = array(DRUPAL_BOOTSTRAP_CONFIGURATION, DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_ACCESS, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE, DRUPAL_BOOTSTRAP_LANGUAGE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL), $phase_index = 0;
// Stop early if $phase was already executed.
if (!in_array($phase, $phases)) {
if ($phase < $phase_index) {
return;
}
while (!is_null($current_phase = array_shift($phases))) {
while (!empty($phases)) {
$current_phase = $phases[$phase_index];
unset($phases[$phase_index]);
_drupal_bootstrap($current_phase);
$phase_index++;
if ($phase == $current_phase) {
return;
}
......
......@@ -380,8 +380,9 @@ function module_implements($hook, $sort = FALSE, $refresh = FALSE) {
*/
function module_invoke() {
$args = func_get_args();
$module = array_shift($args);
$hook = array_shift($args);
$module = $args[0];
$hook = $args[1];
unset($args[0], $args[1]);
$function = $module .'_'. $hook;
if (module_hook($module, $hook)) {
return call_user_func_array($function, $args);
......@@ -400,7 +401,8 @@ function module_invoke() {
*/
function module_invoke_all() {
$args = func_get_args();
$hook = array_shift($args);
$hook = $args[0];
unset($args[0]);
$return = array();
foreach (module_implements($hook) as $module) {
$function = $module .'_'. $hook;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment