summaryrefslogtreecommitdiff
path: root/inc/indexer.php
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2014-03-12 18:20:33 +0000
committerChristopher Smith <chris@jalakai.co.uk>2014-03-12 18:20:33 +0000
commitc6568d42d53cab0d8fef498f00a3b9f30d7403ad (patch)
treead37c20752f862ecb6fd08351ccbcab3efecf615 /inc/indexer.php
parent069942acdaa5ba825bc3f92c7093b5071789f1ca (diff)
downloadrpg-c6568d42d53cab0d8fef498f00a3b9f30d7403ad.tar.gz
rpg-c6568d42d53cab0d8fef498f00a3b9f30d7403ad.tar.bz2
Refactor updateTuple()
The existing function was difficult to follow. It worked when adding a new tuple, but not in the most sensible manner.
Diffstat (limited to 'inc/indexer.php')
-rw-r--r--inc/indexer.php15
1 files changed, 7 insertions, 8 deletions
diff --git a/inc/indexer.php b/inc/indexer.php
index a167db47f..5ca2f0bb1 100644
--- a/inc/indexer.php
+++ b/inc/indexer.php
@@ -1218,19 +1218,18 @@ class Doku_Indexer {
* @author Tom N Harris <tnharris@whoopdedo.org>
*/
protected function updateTuple($line, $id, $count) {
- $newLine = $line;
- if ($newLine !== ''){
- $newLine = preg_replace('/(^|:)'.preg_quote($id,'/').'\*\d*/', '', $newLine);
+ if ($line != ''){
+ $line = preg_replace('/(^|:)'.preg_quote($id,'/').'\*\d*/', '', $line);
}
- $newLine = trim($newLine, ':');
+ $line = trim($line, ':');
if ($count) {
- if (strlen($newLine) > 0) {
- return "$id*$count:".$newLine;
+ if ($line) {
+ return "$id*$count:".$line;
} else {
- return "$id*$count".$newLine;
+ return "$id*$count";
}
}
- return $newLine;
+ return $line;
}
/**