vector: reduce allocations

This commit is contained in:
Hajime Hoshi 2024-08-10 05:35:29 +09:00
parent e8e458802d
commit cdb430b2a5

View File

@ -557,12 +557,13 @@ func (p *Path) AppendVerticesAndIndicesForStroke(vertices []ebiten.Vertex, indic
return vertices, indices return vertices, indices
} }
var rects [][4]point
for _, subpath := range p.ensureSubpaths() { for _, subpath := range p.ensureSubpaths() {
if subpath.pointCount() < 2 { if subpath.pointCount() < 2 {
continue continue
} }
var rects [][4]point rects = rects[:0]
for i := 0; i < subpath.pointCount()-1; i++ { for i := 0; i < subpath.pointCount()-1; i++ {
pt := subpath.points[i] pt := subpath.points[i]