Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 1eede1b

Browse files
committed
Avoid string concat array allocation in ActivityTracker
`ActivityTracker+ActivityInfo.ToString()` currently uses `string.Concat(string[])` which requires a `string[]` allocation. The `string[]` allocation can be avoided by modifying the code slightly.
1 parent 85574fc commit 1eede1b

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/mscorlib/src/System/Diagnostics/Eventing/ActivityTracker.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,7 @@ public static string Path(ActivityInfo activityInfo)
328328

329329
public override string ToString()
330330
{
331-
string dead = "";
332-
if (m_stopped != 0)
333-
dead = ",DEAD";
334-
return m_name + "(" + Path(this) + dead + ")";
331+
return m_name + "(" + Path(this) + (m_stopped != 0 ? ",DEAD)" : ")");
335332
}
336333

337334
public static string LiveActivities(ActivityInfo list)

0 commit comments

Comments
 (0)