From 3a48f643707802fdedfec095637bd8dc24c9d610 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 14 Jan 2012 02:15:31 -0430 Subject: [PATCH] Optimizing and simplifying Configure::write(), this also allows arbitrary nesting limit in configure keys --- lib/Cake/Core/Configure.php | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index 67cabfc50..7871930d1 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -124,26 +124,12 @@ class Configure { } foreach ($config as $name => $value) { - if (strpos($name, '.') === false) { - self::$_values[$name] = $value; - } else { - $names = explode('.', $name, 4); - switch (count($names)) { - case 2: - self::$_values[$names[0]][$names[1]] = $value; - break; - case 3: - self::$_values[$names[0]][$names[1]][$names[2]] = $value; - break; - case 4: - $names = explode('.', $name, 2); - if (!isset(self::$_values[$names[0]])) { - self::$_values[$names[0]] = array(); - } - self::$_values[$names[0]] = Set::insert(self::$_values[$names[0]], $names[1], $value); - break; - } + $pointer = &self::$_values; + foreach (explode('.', $name) as $key) { + $pointer = &$pointer[$key]; } + $pointer = $value; + unset($pointer); } if (isset($config['debug']) && function_exists('ini_set')) {