Compacting echos

All of the extra instructions are converted to echos of different types.  As a result, we end up with many consecutive echos, many of them with string literals. If left alone, it would be a complete drag in the performance of the resulting code.   The compact_echo plugin handles that.  The source files compact_echo.h and compact_echo.cpp are a separate plugin, usefull on its own, besides the pre-compiler.

 Compact_echo will convert this:

<?php
	echo "1" . (1 . $a ), 'ab';
	echo 'c' ,2;
	if ($a) {
		echo 2;
		//$a=1;
		echo $a;
	}
?>

Into this:

<?php
	echo "1", 1, $a, "abc", 2;
	if($a)
	{
		echo 2, $a;
	}
?>

Notice it compacts into a single echo the echos found in multiple lines, ignoring intermediate comments and it replaces the string concatenation operator (.) by simply echoing each operand as a separate argument, which is faster.  On the other hand, if there are two consecutive string literals, it concatenates them into a single one at pre-compile time, which saves time at execution time.

< Previous: Escaped echo

Up

Next: Validation >