delete Release conditional Log methods that create garbage regardless of condition
replace garbage generating calls with garbage free alternatives, use PoolList<T> where applicable
refactor delegates capturing method variables either by removing delegate or forcing delegate instantiation to last moment
correct Assertion type to avoid boxing, fix possible NullReferenceException while logging an Exception 😂
skip queuing notify actions if there's no listeners in the Notifier class. Avoids creating useless Simulation Action and also eliminates garbage that would be generated by instantiating objects args and Action delegate itself
Important note after checking compiled code in Release target
Debug guarded calls with lambdas or delegates capturing local variable (debugOverlay in UpdatePathTargetPositionsPatch.cs captures Bezier3 variable) can still trigger generation of <>DisplayClass helper classes, and most importantly use the instance of helper class to move captured variable around even if debug guarded code is not used explicitly anywhere in the method.
Other notes
Lambda/Delegate capturing local variable generates <>DisplayClass which instance in most cases is created in the first line of the method, regardless of where it be actually used, so compiler will generate instantiation code just for passing captured value around, even if you guard the explicit call with multiple conditions, including const.
TODO for the future PR
Redesign SegmentTraverser and SegmentLaneTraverser since currently they are multi-level garbage generators with lambdas capturing other lambdas, capturing local variables, not to mention that one runs recursively.
Used on the main thread, mostly for displaying mod overlays like clickable Speed limits signs handles, Parking restrictions etc.
Release
conditional Log methods that create garbage regardless of conditionPoolList<T>
where applicableAssertion
type to avoid boxing, fix possibleNullReferenceException
while logging anException
😂Notifier
class. Avoids creating uselessSimulation Action
and also eliminates garbage that would be generated by instantiating objects args andAction
delegate itselfImportant note after checking compiled code in
Release
targetDebug guarded calls with lambdas or delegates capturing local variable (
debugOverlay
inUpdatePathTargetPositionsPatch.cs
captures Bezier3 variable) can still trigger generation of<>DisplayClass
helper classes, and most importantly use the instance of helper class to move captured variable around even if debug guarded code is not used explicitly anywhere in the method.Other notes
Lambda/Delegate capturing local variable generates
<>DisplayClass
which instance in most cases is created in the first line of the method, regardless of where it be actually used, so compiler will generate instantiation code just for passing captured value around, even if you guard the explicit call with multiple conditions, includingconst
.TODO for the future PR
Redesign
SegmentTraverser
andSegmentLaneTraverser
since currently they are multi-level garbage generators with lambdas capturing other lambdas, capturing local variables, not to mention that one runs recursively. Used on the main thread, mostly for displaying mod overlays like clickable Speed limits signs handles, Parking restrictions etc.Build ZIP