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

@@ -74,10 +74,15 @@ namespace OpenRA.Traits
public static Activity RunActivity(Actor self, Activity act)
{
// PERF: If there are no activities we can bail straight away and save ourselves a call to
// Stopwatch.GetTimestamp.
if (act == null)
return act;
// Note - manual iteration 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: DoTimed
var longTickThresholdInStopwatchTicks = PerfTimer.LongTickThresholdInStopwatchTicks;
var start = Stopwatch.GetTimestamp();
while (act != null)