File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,11 @@ class OutputFormatter
12
12
*/
13
13
private $ oFormat ;
14
14
15
+ /**
16
+ * @var array<string, string>
17
+ */
18
+ private $ preparedSpacesCache = [];
19
+
15
20
public function __construct (OutputFormat $ oFormat )
16
21
{
17
22
$ this ->oFormat = $ oFormat ;
@@ -241,7 +246,13 @@ public function comments(Commentable $oCommentable)
241
246
*/
242
247
private function prepareSpace ($ sSpaceString )
243
248
{
244
- return str_replace ("\n" , "\n" . $ this ->indent (), $ sSpaceString );
249
+ $ cacheKey = $ this ->oFormat ->level () . $ sSpaceString ;
250
+
251
+ if (isset ($ this ->preparedSpacesCache [$ cacheKey ])) {
252
+ return $ this ->preparedSpacesCache [$ cacheKey ];
253
+ }
254
+
255
+ return $ this ->preparedSpacesCache [$ cacheKey ] = str_replace ("\n" , "\n" . $ this ->indent (), $ sSpaceString );
245
256
}
246
257
247
258
/**
You can’t perform that action at this time.
0 commit comments