1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 06:04:57 +00:00

LibGL: Optimize appends in gl_vertex

Optimize a very hot function by always performing unchecked appends.
When benchmarking 3DFileViewer on my machine, this takes the time spent
in `gl_vertex` down from ~8% to ~2%.
This commit is contained in:
Jelle Raaijmakers 2023-10-05 22:39:59 +02:00
parent edcb6176ce
commit c978891dda

View file

@ -295,7 +295,10 @@ void GLContext::gl_vertex(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
vertex.tex_coords[i] = m_current_vertex_tex_coord[i];
vertex.normal = m_current_vertex_normal;
m_vertex_list.append(vertex);
// Optimization: by pulling in the Vector size vs. capacity check, we can always perform an unchecked append
if (m_vertex_list.size() == m_vertex_list.capacity())
m_vertex_list.grow_capacity(m_vertex_list.size() + 1);
m_vertex_list.unchecked_append(vertex);
}
void GLContext::gl_vertex_pointer(GLint size, GLenum type, GLsizei stride, void const* pointer)