summaryrefslogtreecommitdiff
path: root/inc/pageutils.php
diff options
context:
space:
mode:
authorChris Tapp <chris.tapp@keylevel.com>2010-02-28 11:54:30 +0100
committerAndreas Gohr <andi@splitbrain.org>2010-02-28 11:54:30 +0100
commit01e3159c01c6e13a9a102bd4c1e09b852c994223 (patch)
tree540f3eb01f60f0b46e16814fb502f28b0ca80297 /inc/pageutils.php
parentbc87043b7847c13380205af0accec67b3d7dc974 (diff)
downloadrpg-01e3159c01c6e13a9a102bd4c1e09b852c994223.tar.gz
rpg-01e3159c01c6e13a9a102bd4c1e09b852c994223.tar.bz2
Better performance on assigning section IDs FS#1894
Diffstat (limited to 'inc/pageutils.php')
-rw-r--r--inc/pageutils.php11
1 files changed, 5 insertions, 6 deletions
diff --git a/inc/pageutils.php b/inc/pageutils.php
index b6b1d048b..33b93bd72 100644
--- a/inc/pageutils.php
+++ b/inc/pageutils.php
@@ -198,7 +198,7 @@ function noNSorNS($id) {
* Creates a XHTML valid linkid from a given headline title
*
* @param string $title The headline title
- * @param array $check List of existing IDs
+ * @param array $check Existing IDs (title => number)
* @author Andreas Gohr <andi@splitbrain.org>
*/
function sectionID($title,&$check) {
@@ -212,12 +212,11 @@ function sectionID($title,&$check) {
if(is_array($check)){
// make sure tiles are unique
- $num = '';
- while(in_array($title.$num,$check)){
- ($num) ? $num++ : $num = 1;
+ if (!array_key_exists ($title,$check)) {
+ $check[$title] = 0;
+ } else {
+ $title .= ++ $check[$title];
}
- $title = $title.$num;
- $check[] = $title;
}
return $title;