mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 11:12:44 +01:00
internal/graphicscommand: add a debug.IsDebug check before splitting strings (#3134)
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).
This commit is contained in:
parent
0ec2c4bfd0
commit
2ad0e9a9db
@ -305,14 +305,16 @@ func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, endFrame bo
|
|||||||
if err := c.Exec(q, graphicsDriver, indexOffset); err != nil {
|
if err := c.Exec(q, graphicsDriver, indexOffset); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
str := c.String()
|
if debug.IsDebug {
|
||||||
for {
|
str := c.String()
|
||||||
head, tail, ok := strings.Cut(str, "\n")
|
for {
|
||||||
logger.FrameLogf(" %s\n", head)
|
head, tail, ok := strings.Cut(str, "\n")
|
||||||
if !ok {
|
logger.FrameLogf(" %s\n", head)
|
||||||
break
|
if !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
str = tail
|
||||||
}
|
}
|
||||||
str = tail
|
|
||||||
}
|
}
|
||||||
// TODO: indexOffset should be reset if the command type is different
|
// TODO: indexOffset should be reset if the command type is different
|
||||||
// from the previous one. This fix is needed when another drawing command is
|
// from the previous one. This fix is needed when another drawing command is
|
||||||
|
Loading…
Reference in New Issue
Block a user