Directly run unsynced functions if we don't check sync hashes
This commit is contained in:
@@ -181,10 +181,10 @@ namespace OpenRA
|
|||||||
public static T RunUnsynced<T>(bool checkSyncHash, World world, Func<T> fn)
|
public static T RunUnsynced<T>(bool checkSyncHash, World world, Func<T> fn)
|
||||||
{
|
{
|
||||||
// PERF: Detect sync changes in top level entry point only. Do not recalculate sync hash during reentry.
|
// PERF: Detect sync changes in top level entry point only. Do not recalculate sync hash during reentry.
|
||||||
if (inUnsyncedCode || world == null)
|
if (!checkSyncHash || inUnsyncedCode || world == null)
|
||||||
return fn();
|
return fn();
|
||||||
|
|
||||||
var sync = checkSyncHash ? world.SyncHash() : 0;
|
var sync = world.SyncHash();
|
||||||
inUnsyncedCode = true;
|
inUnsyncedCode = true;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -194,7 +194,7 @@ namespace OpenRA
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
inUnsyncedCode = false;
|
inUnsyncedCode = false;
|
||||||
if (checkSyncHash && sync != world.SyncHash())
|
if (sync != world.SyncHash())
|
||||||
throw new InvalidOperationException("RunUnsynced: sync-changing code may not run here");
|
throw new InvalidOperationException("RunUnsynced: sync-changing code may not run here");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user