Skip to content

Commit 7108d38

Browse files
committed
Switch a few global slices to arrays
Use the [...] syntax to have an array with the capacity of the number of items it has when created. This should likely allow the compiler/runtime to proove that it cannot grow.
1 parent cbb0fd3 commit 7108d38

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

cmd/fyne_settings/settings/scale.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type scaleItems struct {
1515
button *widget.Button
1616
}
1717

18-
var scales = []*scaleItems{
18+
var scales = [...]*scaleItems{
1919
{scale: 0.5, name: "Tiny"},
2020
{scale: 0.8, name: "Small"},
2121
{scale: 1, name: "Normal"},

internal/painter/gl/gl_core.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type (
5757
Uniform int32
5858
)
5959

60-
var textureFilterToGL = []int32{gl.LINEAR, gl.NEAREST, gl.LINEAR}
60+
var textureFilterToGL = [...]int32{gl.LINEAR, gl.NEAREST, gl.LINEAR}
6161

6262
func (p *painter) Init() {
6363
p.ctx = &coreContext{}

internal/painter/gl/gl_es.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type (
5757
Uniform int32
5858
)
5959

60-
var textureFilterToGL = []int32{gl.LINEAR, gl.NEAREST, gl.LINEAR}
60+
var textureFilterToGL = [...]int32{gl.LINEAR, gl.NEAREST, gl.LINEAR}
6161

6262
func (p *painter) Init() {
6363
p.ctx = &esContext{}

internal/painter/gl/gl_gomobile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type (
5757
var compiled []Program // avoid multiple compilations with the re-used mobile GUI context
5858
var noBuffer = Buffer{}
5959
var noShader = Shader{}
60-
var textureFilterToGL = []int32{gl.Linear, gl.Nearest}
60+
var textureFilterToGL = [...]int32{gl.Linear, gl.Nearest}
6161

6262
func (p *painter) glctx() gl.Context {
6363
return p.contextProvider.Context().(gl.Context)

internal/painter/gl/gl_wasm.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type (
5454

5555
var noBuffer = Buffer(gl.NoBuffer)
5656
var noShader = Shader(gl.NoShader)
57-
var textureFilterToGL = []int32{gl.LINEAR, gl.NEAREST}
57+
var textureFilterToGL = [...]int32{gl.LINEAR, gl.NEAREST}
5858

5959
func (p *painter) Init() {
6060
p.ctx = &xjsContext{}

test/theme.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
var defaultTheme fyne.Theme
1515

1616
// Try to keep these in sync with the existing color names at theme/color.go.
17-
var knownColorNames = []fyne.ThemeColorName{
17+
var knownColorNames = [...]fyne.ThemeColorName{
1818
theme.ColorNameBackground,
1919
theme.ColorNameButton,
2020
theme.ColorNameDisabled,

0 commit comments

Comments
 (0)