Skip to content
Snippets Groups Projects
Commit 01e3159c authored by Chris Tapp's avatar Chris Tapp Committed by Andreas Gohr
Browse files

Better performance on assigning section IDs FS#1894

parent bc87043b
No related branches found
No related tags found
No related merge requests found
...@@ -198,7 +198,7 @@ function noNSorNS($id) { ...@@ -198,7 +198,7 @@ function noNSorNS($id) {
* Creates a XHTML valid linkid from a given headline title * Creates a XHTML valid linkid from a given headline title
* *
* @param string $title The 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> * @author Andreas Gohr <andi@splitbrain.org>
*/ */
function sectionID($title,&$check) { function sectionID($title,&$check) {
...@@ -212,12 +212,11 @@ function sectionID($title,&$check) { ...@@ -212,12 +212,11 @@ function sectionID($title,&$check) {
if(is_array($check)){ if(is_array($check)){
// make sure tiles are unique // make sure tiles are unique
$num = ''; if (!array_key_exists ($title,$check)) {
while(in_array($title.$num,$check)){ $check[$title] = 0;
($num) ? $num++ : $num = 1; } else {
$title .= ++ $check[$title];
} }
$title = $title.$num;
$check[] = $title;
} }
return $title; return $title;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment