summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2010-11-15 22:08:06 +0100
committerMichael Hamann <michael@content-space.de>2010-11-15 22:08:06 +0100
commit06af2d035180c4fb746a9b88c11178c516c88092 (patch)
tree241f538d10613936b8e45be9a057bddd5784737f
parent430d05b058ac3df435600a678cda365dba3eb1b7 (diff)
downloadrpg-06af2d035180c4fb746a9b88c11178c516c88092.tar.gz
rpg-06af2d035180c4fb746a9b88c11178c516c88092.tar.bz2
Indexer speed improvement: joined array vs. single lines
From my experience with a benchmark of the indexer it is faster to first join the array of all index entries and then write them back together instead of writing every single entry. This might increase memory usage, but I couldn't see a significant increase and this function is also only used for the small index files, not for the large pagewords index.
-rw-r--r--inc/indexer.php4
1 files changed, 1 insertions, 3 deletions
diff --git a/inc/indexer.php b/inc/indexer.php
index f5330040a..0a7e2265e 100644
--- a/inc/indexer.php
+++ b/inc/indexer.php
@@ -67,9 +67,7 @@ function idx_saveIndex($pre, $wlen, &$idx){
$fn = $conf['indexdir'].'/'.$pre.$wlen;
$fh = @fopen($fn.'.tmp','w');
if(!$fh) return false;
- foreach ($idx as $line) {
- fwrite($fh,$line);
- }
+ fwrite($fh,join('', $idx));
fclose($fh);
if(isset($conf['fperm'])) chmod($fn.'.tmp', $conf['fperm']);
io_rename($fn.'.tmp', $fn.'.idx');