From 1f7fcf6f3868e31d8b93816812f5ff251e423e33 Mon Sep 17 00:00:00 2001 From: real_nowhereman Date: Tue, 17 Nov 2009 15:25:45 +0000 Subject: [PATCH] caching_BPT/caching_SBPT did NOT really cache a heck, sinche $cache was the local variable! also, fixed broken pass-by-ref which broke loose search for SBPT --- fp-includes/core/core.bplustree.class.php | 25 +++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/fp-includes/core/core.bplustree.class.php b/fp-includes/core/core.bplustree.class.php index 34b1adc..13ee835 100755 --- a/fp-includes/core/core.bplustree.class.php +++ b/fp-includes/core/core.bplustree.class.php @@ -1759,8 +1759,8 @@ class BPlusTree { * @param $key target key * @returns bool false if key does not exists, true otherwise */ - function has_key($key) { - if (@$this->getitem($key)!==false) { + function has_key(&$key, $loose=false) { + if (@$this->getitem($key, $loose)!==false) { return true; } else { return false; @@ -2510,9 +2510,12 @@ class caching_BPT extends BPlusTree { var $cache = array(); function getitem(&$key, $loose=false) { - if (isset($cache[$key])) - return $cache[$key]; - else return ($cache[$key] = parent::getitem($key, $loose)); + if (isset($this->cache[$key])) + return $this->cache[$key]; + else { + $this->cache[$key] = parent::getitem($key, $loose); + return $this->cache[$key]; + } } function resetcache() { @@ -2577,7 +2580,7 @@ class SBPlusTree extends BPlusTree { * @param $key target key * @returns int seek point if key exists, 0 otherwise */ - function has_key($key, $loose=false) { + function has_key(&$key, $loose=false) { return @parent::getitem($key, $loose); } @@ -2628,9 +2631,13 @@ class caching_SBPT extends SBPlusTree { } function getitem(&$key, $loose=false) { - if (isset($cache[$key])) - return $cache[$key]; - else return ($cache[$key] = parent::getitem($key, $loose)); + if (isset($this->cache[$key])) + return $this->cache[$key]; + else { + $item = parent::getitem($key, $loose); + $this->cache[$key] = $item; + return $item; + } } function resetcache() {