mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
graphics: Avoid calling Len() too many times
This commit is contained in:
parent
537cfea8a4
commit
f5b4179142
@ -48,10 +48,11 @@ func drawTexture(c *opengl.Context, texture opengl.Texture, projectionMatrix *[4
|
|||||||
shadersInitialized = true
|
shadersInitialized = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if quads.Len() == 0 {
|
l := quads.Len()
|
||||||
|
if l == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if quadsMaxNum < quads.Len() {
|
if quadsMaxNum < l {
|
||||||
return errors.New(fmt.Sprintf("len(quads) must be equal to or less than %d", quadsMaxNum))
|
return errors.New(fmt.Sprintf("len(quads) must be equal to or less than %d", quadsMaxNum))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ func drawTexture(c *opengl.Context, texture opengl.Texture, projectionMatrix *[4
|
|||||||
p.begin()
|
p.begin()
|
||||||
defer p.end()
|
defer p.end()
|
||||||
|
|
||||||
for i := 0; i < quads.Len(); i++ {
|
for i := 0; i < l; i++ {
|
||||||
x0, y0, x1, y1 := quads.Vertex(i)
|
x0, y0, x1, y1 := quads.Vertex(i)
|
||||||
u0, v0, u1, v1 := quads.Texture(i)
|
u0, v0, u1, v1 := quads.Texture(i)
|
||||||
vertices[16*i] = int16(x0)
|
vertices[16*i] = int16(x0)
|
||||||
|
Loading…
Reference in New Issue
Block a user