Optimizing Configure::delete(), you can now delete arbitrarily nested keys

This commit is contained in:
Jose Lorenzo Rodriguez 2012-01-14 23:30:31 -04:30
parent eab2d8aa66
commit 81b41aa561

View file

@ -188,13 +188,13 @@ class Configure {
* @return void
*/
public static function delete($var = null) {
if (strpos($var, '.') === false) {
unset(self::$_values[$var]);
return;
$keys = explode('.', $var);
$last = array_pop($keys);
$pointer = &self::$_values;
foreach ($keys as $key) {
$pointer = &$pointer[$key];
}
$names = explode('.', $var, 2);
self::$_values[$names[0]] = Set::remove(self::$_values[$names[0]], $names[1]);
unset($pointer[$last]);
}
/**