summaryrefslogtreecommitdiff
path: root/inc/pageutils.php
diff options
context:
space:
mode:
authorchris <chris@jalakai.co.uk>2006-08-27 17:33:52 +0200
committerchris <chris@jalakai.co.uk>2006-08-27 17:33:52 +0200
commit6e0cc83a924bf9b5f90ae80f11ccdcf58ee415a7 (patch)
tree93cd018f7d436835fcd4c66faf15d39a1c674ed4 /inc/pageutils.php
parentf50163d1d772ac773f6d03ed049e4a0329674db9 (diff)
downloadrpg-6e0cc83a924bf9b5f90ae80f11ccdcf58ee415a7.tar.gz
rpg-6e0cc83a924bf9b5f90ae80f11ccdcf58ee415a7.tar.bz2
add function result caching for cleanID and wikiFN
darcs-hash:20060827153352-9b6ab-651decb2566f16334218c6782edc6c7d47b41e13.gz
Diffstat (limited to 'inc/pageutils.php')
-rw-r--r--inc/pageutils.php28
1 files changed, 23 insertions, 5 deletions
diff --git a/inc/pageutils.php b/inc/pageutils.php
index c2cd29bf1..02330e2a4 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -65,19 +65,26 @@ function getID($param='id',$clean=true){
* converted to unaccented ones
*
* @author Andreas Gohr <andi@splitbrain.org>
- * @param string $id The pageid to clean
- * @param boolean $ascii Force ASCII
+ * @param string $raw_id The pageid to clean
+ * @param boolean $ascii Force ASCII
*/
-function cleanID($id,$ascii=false){
+function cleanID($raw_id,$ascii=false){
global $conf;
global $lang;
static $sepcharpat = null;
+ static $cache = array();
+
+ // check if it's already in the memory cache
+ if (isset($cache[$raw_id])) {
+ return $cache[$raw_id];
+ }
+
$sepchar = $conf['sepchar'];
if($sepcharpat == null) // build string only once to save clock cycles
$sepcharpat = '#\\'.$sepchar.'+#';
- $id = trim($id);
+ $id = trim($raw_id);
$id = utf8_strtolower($id);
//alternative namespace seperator
@@ -102,6 +109,7 @@ function cleanID($id,$ascii=false){
$id = trim($id,':._-');
$id = preg_replace('#:[:\._\-]+#',':',$id);
+ $cache[$raw_id] = $id;
return($id);
}
@@ -140,8 +148,16 @@ function noNS($id) {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
-function wikiFN($id,$rev='',$clean=true){
+function wikiFN($raw_id,$rev='',$clean=true){
global $conf;
+
+ static $cache = array();
+ if (isset($cache[$raw_id]) && isset($cache[$raw_id][$rev])) {
+ return $cache[$raw_id][$rev];
+ }
+
+ $id = $raw_id;
+
if ($clean) $id = cleanID($id);
$id = str_replace(':','/',$id);
if(empty($rev)){
@@ -160,6 +176,8 @@ function wikiFN($id,$rev='',$clean=true){
}
}
}
+
+ $cache[$raw_id][$rev] = $fn;
return $fn;
}