Skip to content

Commit

Permalink
internal/graphicscommand: debug.IsDebug check to prevent strings.Cut …
Browse files Browse the repository at this point in the history
…allocations if the debugger is disabled
  • Loading branch information
gabstv committed Oct 18, 2024
1 parent 0ec2c4b commit f4cb7e5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions internal/graphicscommand/commandqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"image"
"math"

"strings"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -305,14 +306,16 @@ func (q *commandQueue) flush(graphicsDriver graphicsdriver.Graphics, endFrame bo
if err := c.Exec(q, graphicsDriver, indexOffset); err != nil {
return err
}
str := c.String()
for {
head, tail, ok := strings.Cut(str, "\n")
logger.FrameLogf(" %s\n", head)
if !ok {
break
if debug.IsDebug {
str := c.String()
for {
head, tail, ok := strings.Cut(str, "\n")
logger.FrameLogf(" %s\n", head)
if !ok {
break
}
str = tail
}
str = tail
}
// TODO: indexOffset should be reset if the command type is different
// from the previous one. This fix is needed when another drawing command is
Expand Down

0 comments on commit f4cb7e5

Please sign in to comment.