Faster `Exporter-> exportString()`

This commit is contained in:
Markus Staab 2024-06-18 11:49:45 +02:00 committed by Sebastian Bergmann
parent 043643c365
commit 8474a9eeef
1 changed files with 9 additions and 8 deletions

View File

@ -30,6 +30,7 @@ use function spl_object_id;
use function sprintf;
use function str_repeat;
use function str_replace;
use function strtr;
use function var_export;
use BackedEnum;
use ReflectionObject;
@ -320,14 +321,14 @@ final readonly class Exporter
}
return "'" .
str_replace(
'<lf>',
"\n",
str_replace(
["\r\n", "\n\r", "\r", "\n"],
['\r\n<lf>', '\n\r<lf>', '\r<lf>', '\n<lf>'],
$value,
),
strtr(
$value,
[
"\r\n" => '\r\n' . "\n",
"\n\r" => '\n\r' . "\n",
"\r" => '\r' . "\n",
"\n" => '\n' . "\n",
],
) .
"'";
}