Skip to content

Commit 9a070ee

Browse files
author
André L F S Bacci
committed
Output buffer 'matter' simplification.
1 parent bdd9ffb commit 9a070ee

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

scripts/translation/lib/OutputIgnoreBuffer.php

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class OutputIgnoreBuffer
2525

2626
private string $filename = "";
2727
private string $header = "";
28-
private array $texts = array();
28+
private array $matter = array();
2929
private array $footer = array();
3030

3131
private OutputIgnoreArgv $args;
@@ -39,7 +39,7 @@ function __construct( OutputIgnoreArgv $args , string $header , string $filename
3939

4040
function add( string $text )
4141
{
42-
$this->texts[] = $text;
42+
$this->matter[] = $text;
4343
}
4444

4545
function addDiff( string $text , int $sourceCount , int $targetCount )
@@ -68,18 +68,15 @@ function addFooter( string $text )
6868

6969
function addLine()
7070
{
71-
if ( count( $this->texts ) > 0 && end( $this->texts ) != "\n" )
71+
if ( count( $this->matter ) > 0 && end( $this->matter ) != "\n" )
7272
$this->add( "\n" );
7373
}
7474

7575
function print()
7676
{
77-
if ( count( $this->texts ) == 0 )
77+
if ( count( $this->matter ) == 0 )
7878
return;
79-
80-
$this->addLine( "\n" );
81-
if ( count ( $this->texts ) > 0 )
82-
$this->printCount++;
79+
$this->printCount++;
8380

8481
// footer
8582

@@ -92,11 +89,11 @@ function print()
9289
// --add-ignore
9390

9491
if ( in_array( $markfull , $marks ) )
95-
$this->texts = array();
92+
$this->matter = array();
9693
else
9794
$this->args->pushAddIgnore( $this , $markfull );
9895

99-
// remove duplicates
96+
// Avoid dupliocates on output
10097

10198
while ( in_array( $markfull , $marks ) )
10299
{
@@ -112,29 +109,29 @@ function print()
112109
$this->args->pushDelIgnore( $this , $mark );
113110
}
114111

115-
$this->addLine( "\n" );
116-
117-
if ( count( $this->texts ) == 0 )
112+
if ( count( $this->matter ) == 0 && count( $this->footer ) == 0 )
118113
return;
119114

120115
print $this->header;
121116

122-
foreach( $this->texts as $text )
117+
foreach( $this->matter as $text )
118+
print $text;
119+
120+
if ( count( $this->matter ) )
121+
print "\n";
122+
123+
foreach( $this->footer as $text )
123124
print $text;
124125

125126
if ( count( $this->footer ) )
126-
{
127-
foreach( $this->footer as $text )
128-
print $text;
129127
print "\n";
130-
}
131128
}
132129

133130
private function hash( bool $withContents ) : string
134131
{
135132
$text = $this->header . $this->args->options;
136133
if ( $withContents )
137-
$text .= implode( "" , $this->texts );
134+
$text .= implode( "" , $this->matter );
138135
$text = str_replace( " " , "" , $text );
139136
$text = str_replace( "\n" , "" , $text );
140137
$text = str_replace( "\r" , "" , $text );

0 commit comments

Comments
 (0)