From b6593acc83546b82367000213d401ea20fc6ed3c Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Fri, 4 Nov 2022 19:24:12 +0000 Subject: [PATCH] Switches instead of if ladders --- GL/draw.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/GL/draw.c b/GL/draw.c index 6a4441a..654feb4 100644 --- a/GL/draw.c +++ b/GL/draw.c @@ -866,14 +866,15 @@ static void generate(SubmissionTarget* target, const GLenum mode, const GLsizei if(indices) { generateElementsFastPath(target, first, count, indices, type); } else { - if(mode == GL_QUADS) { - generateArraysFastPath_QUADS(target, first, count); - return; // Don't need to do any more processing - } else if(mode == GL_TRIANGLES) { - generateArraysFastPath_TRIS(target, first, count); - return; // Don't need to do any more processing - } else { - generateArraysFastPath_ALL(target, first, count); + switch(mode) { + case GL_QUADS: + generateArraysFastPath_QUADS(target, first, count); + return; // Don't need to do any more processing + case GL_TRIANGLES: + generateArraysFastPath_TRIS(target, first, count); + return; // Don't need to do any more processing + default: + generateArraysFastPath_ALL(target, first, count); } } } else { @@ -1088,12 +1089,18 @@ GL_FORCE_INLINE void submitVertices(GLenum mode, GLsizei first, GLuint count, GL * We optimise the triangle and quad cases. */ if(mode == GL_POLYGON) { - if(count == 3) { - mode = GL_TRIANGLES; - } else if(count == 4) { - mode = GL_QUADS; - } else { - mode = GL_TRIANGLE_FAN; + switch(count) { + case 2: + mode = GL_LINES; + break; + case 3: + mode = GL_TRIANGLES; + break; + case 4: + mode = GL_QUADS; + break; + default: + mode = GL_TRIANGLE_FAN; } }