Skip to content

Commit 0a4b1eb

Browse files
perf: delay string.Replace call
1 parent 364cb1e commit 0a4b1eb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Src/CSharpier.Cli/CommandLineFormatter.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ CancellationToken cancellationToken
228228

229229
async Task FormatFile(
230230
string actualFilePath,
231-
string originalFilePath,
231+
string? originalFilePath = null,
232232
bool warnForUnsupported = false
233233
)
234234
{
@@ -247,6 +247,11 @@ async Task FormatFile(
247247
cancellationToken
248248
);
249249

250+
originalFilePath ??= actualFilePath.Replace(
251+
directoryOrFilePath,
252+
originalDirectoryOrFile
253+
);
254+
250255
if (printerOptions is { Formatter: not Formatter.Unknown })
251256
{
252257
printerOptions.IncludeGenerated = commandLineOptions.IncludeGenerated;
@@ -298,9 +303,7 @@ await FormatPhysicalFile(
298303
"*.*",
299304
SearchOption.AllDirectories
300305
)
301-
.Select(o =>
302-
FormatFile(o, o.Replace(directoryOrFilePath, originalDirectoryOrFile))
303-
)
306+
.Select(o => FormatFile(o))
304307
.ToArray();
305308
try
306309
{

0 commit comments

Comments
 (0)