For historical reference:
I tried this out but it was much slower:
protected function newParseSmileys()
{
$message = '';
$offset = -1;
$smiley_block = true;
do
{
$offset++;
$next_marker = strpos($this->message, "\n", $offset);
$length = max(0, $next_marker - $offset);
$stub = substr($this->message, $offset, $length);
if ($smiley_block)
{
parsesmileys($stub);
$message .= $stub;
}
else
{
$message .= $stub;
}
$offset = $next_marker === false ? $offset : $next_marker;
$smiley_block = !$smiley_block;
} while ($next_marker !== false);
if ($offset !== strlen($this->message))
{
$stub = substr($this->message, $offset);
parsesmileys($stub);
$message .= $stub;
}
$this->message = $message;
//return $message;
}