Permalink
Browse files

Optimizing and simplifying Configure::write(), this also allows arbit…

…rary nesting limit in configure keys
  • Loading branch information...
1 parent 2c5cb11 commit 3a48f643707802fdedfec095637bd8dc24c9d610 @lorenzo lorenzo committed Jan 14, 2012
Showing with 5 additions and 19 deletions.
  1. +5 −19 lib/Cake/Core/Configure.php
@@ -124,26 +124,12 @@ public static function write($config, $value = null) {
}
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')) {

0 comments on commit 3a48f64

Please sign in to comment.