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.
This commit is contained in:
Seebs 2017-06-04 12:55:43 -05:00
parent 9bd9df98f2
commit 1586e600a0
1 changed files with 1 additions and 1 deletions

View File

@ -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() {