Skip to content

Commit

Permalink
Optimizing Configure::delete(), you can now delete arbitrarily nested…
Browse files Browse the repository at this point in the history
… keys
  • Loading branch information
lorenzo committed Jan 15, 2012
1 parent eab2d8a commit 81b41aa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/Cake/Core/Configure.php
Expand Up @@ -188,13 +188,13 @@ public static function read($var = null) {
* @return void * @return void
*/ */
public static function delete($var = null) { public static function delete($var = null) {
if (strpos($var, '.') === false) { $keys = explode('.', $var);
unset(self::$_values[$var]); $last = array_pop($keys);
return; $pointer = &self::$_values;
foreach ($keys as $key) {
$pointer = &$pointer[$key];
} }

unset($pointer[$last]);
$names = explode('.', $var, 2);
self::$_values[$names[0]] = Set::remove(self::$_values[$names[0]], $names[1]);
} }


/** /**
Expand Down

0 comments on commit 81b41aa

Please sign in to comment.