Skip to content

Commit

Permalink
Enum.ToString method is resulting in slow performance. Fix it.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimaTian committed Jan 6, 2025
1 parent 08729bf commit 3117080
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ private async Task ProcessTargetStack(ITaskBuilder taskBuilder)
// Execute all of the tasks on this target.
MSBuildEventSource.Log.TargetStart(currentTargetEntry.Name);
await currentTargetEntry.ExecuteTarget(taskBuilder, _requestEntry, _projectLoggingContext, _cancellationToken);
MSBuildEventSource.Log.TargetStop(currentTargetEntry.Name, currentTargetEntry.Result?.ResultCode.ToString() ?? string.Empty);
MSBuildEventSource.Log.TargetStop(currentTargetEntry.Name, currentTargetEntry.Result?.TargetResultCodeToString(currentTargetEntry.Result.ResultCode) ?? string.Empty);
}

break;
Expand Down
15 changes: 15 additions & 0 deletions src/Build/BackEnd/Shared/TargetResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@ public TargetResultCode ResultCode
}
}

public string TargetResultCodeToString(TargetResultCode code)
{
switch (code)
{
case TargetResultCode.Failure:
return "Failure";
case TargetResultCode.Skipped:
return "Skipped";
case TargetResultCode.Success:
return "Success";
default:
return "";
}
}

/// <summary>
/// Returns the internal result for the target.
/// </summary>
Expand Down

0 comments on commit 3117080

Please sign in to comment.