Improved XLSX Escaper performance for strings with only common/safe characters.

This commit is contained in:
Stefan 2016-09-02 00:26:07 +02:00
parent 277c353984
commit a281bee7d6

View File

@ -95,6 +95,10 @@ class XLSX implements EscaperInterface
*/ */
protected function escapeControlCharacters($string) protected function escapeControlCharacters($string)
{ {
if (1 !== preg_match('~[^A-Za-z0-9\-.:, ]~', $string)) {
return $string;
}
$escapedString = $this->escapeEscapeCharacter($string); $escapedString = $this->escapeEscapeCharacter($string);
return str_replace(array_values($this->controlCharactersEscapingMap), array_keys($this->controlCharactersEscapingMap), $escapedString); return str_replace(array_values($this->controlCharactersEscapingMap), array_keys($this->controlCharactersEscapingMap), $escapedString);
} }