Logging System - Asserts #47
Labels
effort-low
Easy - 1 to 2 hours
priority-medium
Standard task, plan as you see fit.
status-todo
Tasks ready to be worked on.
type-feature
New feature or request
Milestone
Depends on: #33
Taken from a discussion in another repo
When calling
Debug.Assert
it's helpful to have a message associated with the failed assertion. However that string message is always created and passed into the method whether it triggers or not.In some cases this is ok, but sometimes generating the error message is expensive, particularly when the assertion is in a hot loop. Finally, the extra garbage generated can get in the way when profiling and distract from actual memory issues.
The suggested solution is to only create assertion messages when the assertion fails. This can be done via a function pointer.
Example
Log.Assert(bool condition, Func<string> messageProvider);
The text was updated successfully, but these errors were encountered: