ENHANCEMENT: Improved performance of Session::set() and Session::get() when there are no .s in the name

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@83438 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-07-31 05:38:50 +00:00
parent 21ca3123bc
commit 3b7595e8c7

View File

@ -83,6 +83,12 @@ class Session {
}
public function inst_set($name, $val) {
// Quicker execution path for "."-free names
if(strpos($name,'.') === false) {
$this->data[$name] = $val;
$this->changedData[$name] = $val;
} else {
$names = explode('.', $name);
// We still want to do this even if we have strict path checking for legacy code
@ -97,6 +103,7 @@ class Session {
$var = $val;
$diffVar = $val;
}
}
public function inst_addToArray($name, $val) {
$names = explode('.', $name);
@ -115,6 +122,11 @@ class Session {
}
public function inst_get($name) {
// Quicker execution path for "."-free names
if(strpos($name,'.') === false) {
if(isset($this->data[$name])) return $this->data[$name];
} else {
$names = explode('.', $name);
if(!isset($this->data)) {
@ -132,6 +144,7 @@ class Session {
return $var;
}
}
public function inst_clear($name) {
$names = explode('.', $name);