mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
attributes: optimize validation of tex_coord%d_in names
This avoids using sscanf to determine the texture_unit that a tex_coord%d_in attribute name corresponds to since that was showing high on profiles. Instead once we know we have a "tex_coord" name then we can simply use strtoul which is much cheaper and use the returned endptr we get to verify we have a "_in" suffix after the number. Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
d739892a5c
commit
77a7add50e
@ -47,6 +47,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* This isn't defined in the GLES headers */
|
||||
#ifndef GL_UNSIGNED_INT
|
||||
@ -163,7 +164,9 @@ validate_cogl_attribute (const char *name,
|
||||
*name_id = COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY;
|
||||
else if (strncmp (name, "tex_coord", strlen ("tex_coord")) == 0)
|
||||
{
|
||||
if (sscanf (name, "tex_coord%u_in", texture_unit) != 1)
|
||||
char *endptr;
|
||||
*texture_unit = strtoul (name + 9, &endptr, 10);
|
||||
if (strcmp (endptr, "_in") != 0)
|
||||
{
|
||||
g_warning ("Texture coordinate attributes should either be named "
|
||||
"\"cogl_tex_coord\" or named with a texture unit index "
|
||||
|
Loading…
Reference in New Issue
Block a user