summaryrefslogtreecommitdiff
path: root/inc/common.php
diff options
context:
space:
mode:
authorBen Coburn <btcoburn@silicodon.net>2006-05-25 05:04:52 +0200
committerBen Coburn <btcoburn@silicodon.net>2006-05-25 05:04:52 +0200
commit6f6c2468ef0087e958dce76036f38ba4296038f1 (patch)
tree5101e100466e3985dfab3ff67e8b8575d444d58a /inc/common.php
parent9a3288d64bca5fe18d3c72e8a6a73d064ac15e43 (diff)
downloadrpg-6f6c2468ef0087e958dce76036f38ba4296038f1.tar.gz
rpg-6f6c2468ef0087e958dce76036f38ba4296038f1.tar.bz2
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
Diffstat (limited to 'inc/common.php')
-rw-r--r--inc/common.php10
1 files 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);