diff options
author | Christopher Smith <chris@jalakai.co.uk> | 2014-03-12 18:20:33 +0000 |
---|---|---|
committer | Christopher Smith <chris@jalakai.co.uk> | 2014-03-12 18:20:33 +0000 |
commit | c6568d42d53cab0d8fef498f00a3b9f30d7403ad (patch) | |
tree | ad37c20752f862ecb6fd08351ccbcab3efecf615 /inc/indexer.php | |
parent | 069942acdaa5ba825bc3f92c7093b5071789f1ca (diff) | |
download | rpg-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.php | 15 |
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; } /** |