From b74a4a0275ac14ea171e09e43c678751e082de97 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 31 Oct 2021 02:10:44 +0900 Subject: [PATCH] internal/graphicsdriver/opengl: Optimization: Avoid heap allocations --- internal/graphicsdriver/opengl/context_js.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/graphicsdriver/opengl/context_js.go b/internal/graphicsdriver/opengl/context_js.go index ce44ff9eb..c14a6557f 100644 --- a/internal/graphicsdriver/opengl/context_js.go +++ b/internal/graphicsdriver/opengl/context_js.go @@ -517,7 +517,9 @@ func (c *context) uniformFloats(p program, location string, v []float32, typ sha gl.uniformMatrix4fv.Invoke(js.Value(l), false, arr.Call("subarray", 0, len(v))) } default: - panic(fmt.Sprintf("opengl: unexpected type: %s", typ.String())) + // Copy shaderir.Type value to avoid heap allocation of typ. + t := typ + panic(fmt.Sprintf("opengl: unexpected type: %s", t.String())) } return true