From 6f6c2468ef0087e958dce76036f38ba4296038f1 Mon Sep 17 00:00:00 2001 From: Ben Coburn <btcoburn@silicodon.net> Date: Thu, 25 May 2006 05:04:52 +0200 Subject: [PATCH] makes getRevisions faster Makes inc/common.php#getRevisions a little faster. Takes about half as much time as the preg_match. darcs-hash:20060525030452-05dcb-dbff9f9c134a425669ff6a477612737b022fb6bd.gz --- inc/common.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/inc/common.php b/inc/common.php index 75c3e8574..b74621071 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1135,12 +1135,14 @@ function getRevisions($id){ $clid = cleanID($id); if(strrpos($clid,':')) $clid = substr($clid,strrpos($clid,':')+1); //remove path $clid = utf8_encodeFN($clid); - + $clid_len = strlen($clid); if (is_dir($revd) && $dh = opendir($revd)) { while (($file = readdir($dh)) !== false) { - if (is_dir($revd.'/'.$file)) continue; - if (preg_match('/^'.$clid.'\.(\d+)\.txt(\.gz)?$/',$file,$match)){ - $revs[]=$match[1]; + if (substr($file, 0, $clid_len)===$clid) { + $p = strpos($file, '.', $clid_len+1); + if (!$p===false) { + $revs[] = substr($file, $clid_len+1, $p-$clid_len-1); + } } } closedir($dh); -- GitLab