Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Reusing instances of MessageFormatter as it is slightly faster
  • Loading branch information
lorenzo committed Jul 27, 2014
1 parent 278575c commit 263d9e6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/I18n/Formatter/IcuFormatter.php
Expand Up @@ -72,7 +72,13 @@ public function format($locale, $message, array $vars) {
* variables is found
*/
protected function _formatMessage($locale, $message, $vars) {
$formatter = new MessageFormatter($locale, $message);
if (!isset($this->_formatters[$locale])) {
$this->_formatters[$locale] = new MessageFormatter($locale, $message);
} else {
$this->_formatters[$locale]->setPattern($message);
}

$formatter = $this->_formatters[$locale];

if (!$formatter) {
throw new Exception\CannotInstantiateFormatter(
Expand Down

0 comments on commit 263d9e6

Please sign in to comment.