Skip to content

Commit

Permalink
use sync.Once instead to maintain the const optimisations and avoid r…
Browse files Browse the repository at this point in the history
…aces
  • Loading branch information
andydotxyz committed Jan 17, 2025
1 parent 3e7e92d commit dfad1bf
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions internal/build/build.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
// Package build contains information about they type of build currently running.
package build

import "fyne.io/fyne/v2"
import (
"sync"

"fyne.io/fyne/v2"
)

var (
migrateCheck sync.Once

migratedFyneDo bool
)

func MigratedToFyneDo() bool {
if DisableThreadChecks {
return true
}

v, ok := fyne.CurrentApp().Metadata().Migrations["fyneDo"]
if ok {
return v
}
return false
migrateCheck.Do(func() {
v, ok := fyne.CurrentApp().Metadata().Migrations["fyneDo"]
if ok {
migratedFyneDo = v
}
})

return migratedFyneDo
}

0 comments on commit dfad1bf

Please sign in to comment.