mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
buffered: Use a raw function to avoid allocating structs
This commit is contained in:
parent
fc3e8bebe4
commit
3291ec51bb
@ -18,10 +18,6 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
type command struct {
|
||||
f func()
|
||||
}
|
||||
|
||||
var (
|
||||
delayedCommandsFlushable bool
|
||||
|
||||
@ -30,7 +26,7 @@ var (
|
||||
// sizes (#879).
|
||||
//
|
||||
// TODO: Flush the commands only when necessary (#921).
|
||||
delayedCommands []*command
|
||||
delayedCommands []func()
|
||||
delayedCommandsM sync.Mutex
|
||||
)
|
||||
|
||||
@ -42,9 +38,7 @@ func makeDelayedCommandFlushable() {
|
||||
|
||||
func enqueueDelayedCommand(f func()) {
|
||||
delayedCommandsM.Lock()
|
||||
delayedCommands = append(delayedCommands, &command{
|
||||
f: f,
|
||||
})
|
||||
delayedCommands = append(delayedCommands, f)
|
||||
delayedCommandsM.Unlock()
|
||||
}
|
||||
|
||||
@ -57,7 +51,7 @@ func flushDelayedCommands() bool {
|
||||
}
|
||||
|
||||
for _, c := range delayedCommands {
|
||||
c.f()
|
||||
c()
|
||||
}
|
||||
delayedCommands = delayedCommands[:0]
|
||||
return true
|
||||
|
Loading…
Reference in New Issue
Block a user