Added comments in performance sensitive code.

This commit is contained in:
RoosterDragon
2015-12-04 19:38:20 +00:00
parent aaa82339d1
commit b0619a3e25
22 changed files with 76 additions and 11 deletions

View File

@@ -43,7 +43,10 @@ namespace OpenRA
public static void DoTimed<T>(this IEnumerable<T> e, Action<T> a, string text)
{
// Note - manual enumeration here for performance due to high call volume.
// PERF: This is a hot path and must run with minimal added overhead.
// Calling Stopwatch.GetTimestamp is a bit expensive, so we enumerate manually to allow us to call it only
// once per iteration in the normal case.
// See also: RunActivity
var longTickThresholdInStopwatchTicks = PerfTimer.LongTickThresholdInStopwatchTicks;
using (var enumerator = e.GetEnumerator())
{