Ranks/emojione — pull request #4 by s9e (2014-09-12 20:18:09+00:00)
Title: Greatly improve the performance of the PHP implementation

Hello :bowtie:

This branch contains an alternative PHP algorithm for replacing strings. Instead of frontloading hundreds of replacements via `str_replace`, it matches every Emoji or smileys at once with a regular expression and replaces them with a callback. The performance increases tenfold to a hundredfold (hence the branch name) depending on the method called and input provided. Demo 4 with its default input goes from ~4ms to ~60µs on my machine.

A note about those regexps: I wrote `$unicodeRegexp` by hand. It more-or-less matches the Unicode blocks used in Emojione. The callback filters out false positives. `$asciiRegexp` was generated programmatically with the help of [this class](https://github.com/s9e/TextFormatter/blob/master/src/Configurator/Helpers/RegexpBuilder.php), using the following script:

```php
include '/s9e/TextFormatter/src/autoloader.php';
include '/s9e/emojione/lib/php/Emojione.class.php';

$regexp = s9e\TextFormatter\Configurator\Helpers\RegexpBuilder::fromList(
array_keys(Emojione::$ascii_replace),
['delimiter' => '`', 'caseInsensitive' => true]
);
$regexp = '`(?