Since debug.IsDebug is a constant, by putting the strings.Cut calls inside the check this makes the (*commandqueue).flush method faster when Ebitengine is compiled without the debug build tag.
Without the if debug.IsDebug check, unnecessary allocations occur (since the logger is a noop logger when debug is disabled):
GC Details after the change:
This happens because Go knows that IsDebug is a constant (and the compiler will optimize this away on production builds).
What issue is this addressing?
--
What type of issue is this addressing?
feature
What this PR does | solves
Since
debug.IsDebug
is a constant, by putting thestrings.Cut
calls inside the check this makes the(*commandqueue).flush
method faster when Ebitengine is compiled without thedebug
build tag.Without the
if debug.IsDebug
check, unnecessary allocations occur (since the logger is a noop logger when debug is disabled):GC Details after the change:
This happens because Go knows that IsDebug is a constant (and the compiler will optimize this away on production builds).