From ae715ba33b932f967dc42411111c6579d9bd8795 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 3 Dec 2022 01:10:29 +0900 Subject: [PATCH] internal/shaderir: performance improvement by using a slice instead of a map --- internal/shaderir/program.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/shaderir/program.go b/internal/shaderir/program.go index 273b4fa25..8d74c0f68 100644 --- a/internal/shaderir/program.go +++ b/internal/shaderir/program.go @@ -32,7 +32,7 @@ type Program struct { VertexFunc VertexFunc FragmentFunc FragmentFunc - reachableUniforms map[int]struct{} + reachableUniforms []bool } type Func struct { @@ -462,16 +462,16 @@ func (p *Program) reachableUniformVariablesFromBlock(block *Block) []int { func (p *Program) FilterUniformVariables(uniforms [][]uint32) { if p.reachableUniforms == nil { - p.reachableUniforms = map[int]struct{}{} + p.reachableUniforms = make([]bool, len(p.Uniforms)) for _, i := range p.reachableUniformVariablesFromBlock(p.VertexFunc.Block) { - p.reachableUniforms[i] = struct{}{} + p.reachableUniforms[i] = true } for _, i := range p.reachableUniformVariablesFromBlock(p.FragmentFunc.Block) { - p.reachableUniforms[i] = struct{}{} + p.reachableUniforms[i] = true } } for i := range uniforms { - if _, ok := p.reachableUniforms[i]; !ok { + if !p.reachableUniforms[i] { uniforms[i] = nil } }