summaryrefslogtreecommitdiff
path: root/inc/parser/handler.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2011-11-27 10:50:03 +0100
committerAndreas Gohr <andi@splitbrain.org>2011-11-27 10:50:03 +0100
commit560f6ea3cdac2767863c3be3a9e7933b6e37e88f (patch)
tree6f51d4b3402458e4de1a596b93ec752c8ac747b2 /inc/parser/handler.php
parente0dd04a6493f1b7f7133f75c08f9ea55ee8bd50a (diff)
parentc66c7229a0dfc4f9f06dadda98408679fa7a18d6 (diff)
downloadrpg-560f6ea3cdac2767863c3be3a9e7933b6e37e88f.tar.gz
rpg-560f6ea3cdac2767863c3be3a9e7933b6e37e88f.tar.bz2
Merge branch 'master' into bcrypt
Diffstat (limited to 'inc/parser/handler.php')
-rw-r--r--inc/parser/handler.php24
1 files changed, 13 insertions, 11 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index 22a50d1b7..55b715ad9 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -1489,10 +1489,10 @@ class Doku_Handler_Block {
}
}
- function openParagraph($pos){
+ function openParagraph($pos){
if ($this->inParagraph) return;
$this->calls[] = array('p_open',array(), $pos);
- $this->inParagraph = true;
+ $this->inParagraph = true;
$this->skipEol = true;
}
@@ -1503,11 +1503,12 @@ class Doku_Handler_Block {
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
- function closeParagraph($pos){
+ function closeParagraph($pos){
if (!$this->inParagraph) return;
// look back if there was any content - we don't want empty paragraphs
$content = '';
- for($i=count($this->calls)-1; $i>=0; $i--){
+ $ccount = count($this->calls);
+ for($i=$ccount-1; $i>=0; $i--){
if($this->calls[$i][0] == 'p_open'){
break;
}elseif($this->calls[$i][0] == 'cdata'){
@@ -1520,18 +1521,19 @@ class Doku_Handler_Block {
if(trim($content)==''){
//remove the whole paragraph
- array_splice($this->calls,$i);
- }else{
- // remove ending linebreaks in the paragraph
- $i=count($this->calls)-1;
+ //array_splice($this->calls,$i); // <- this is much slower than the loop below
+ for($x=$ccount; $x>$i; $x--) array_pop($this->calls);
+ }else{
+ // remove ending linebreaks in the paragraph
+ $i=count($this->calls)-1;
if ($this->calls[$i][0] == 'cdata') $this->calls[$i][1][0] = rtrim($this->calls[$i][1][0],DOKU_PARSER_EOL);
$this->calls[] = array('p_close',array(), $pos);
}
- $this->inParagraph = false;
+ $this->inParagraph = false;
$this->skipEol = true;
}
-
+
function addCall($call) {
$key = count($this->calls);
if ($key and ($call[0] == 'cdata') and ($this->calls[$key-1][0] == 'cdata')) {
@@ -1553,7 +1555,7 @@ class Doku_Handler_Block {
* @author Andreas Gohr <andi@splitbrain.org>
*/
function process($calls) {
- // open first paragraph
+ // open first paragraph
$this->openParagraph(0);
foreach ( $calls as $key => $call ) {
$cname = $call[0];