From 0358330d3b3f867f390a773e2705d243a4629ba3 Mon Sep 17 00:00:00 2001
From: Seebs <seebs@seebs.net>
Date: Sun, 4 Jun 2017 12:55:43 -0500
Subject: [PATCH] The initializer is surprisingly expensive.

Removing the call to Alpha(1) and replacing it with an inline definition
produces measurable improvements. Replacing each instance of ZV with
Vec{} further improves things. We keep an inline RGBA because there
are circumstances (mostly when using pictures) where we don't want to
have to set colors to get default behavior.

For a fairly triangle-heavy thing, this reduces time spent in SetLen
from something over 10% of execution time to around 2.5% of execution
time.
---
 data.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/data.go b/data.go
index 4e6c528..c941241 100644
--- a/data.go
+++ b/data.go
@@ -45,7 +45,7 @@ func (td *TrianglesData) SetLen(len int) {
 				Color     RGBA
 				Picture   Vec
 				Intensity float64
-			}{ZV, Alpha(1), ZV, 0})
+			}{Color: RGBA{1, 1, 1, 1}})
 		}
 	}
 	if len < td.Len() {
-- 
GitLab