gl: use memcmp to compare glyph cache keys
authorChristian Hergert <chergert@redhat.com>
Wed, 9 Oct 2019 21:46:36 +0000 (14:46 -0700)
committerChristian Hergert <chergert@redhat.com>
Wed, 9 Oct 2019 21:47:23 +0000 (14:47 -0700)
We can just use memcmp here because even in the use of lookup keys with
C99 initializers, we can rely on any space between fields added by the
compiler to be zeroed. So we might as well use wider memory cmopares.

gsk/gl/gskglglyphcache.c

index 5e31369057f35965f9b088302aa155951c744bc6..d1cf5b06f788732dc62b992a155c8d5c52fc173a 100644 (file)
@@ -11,6 +11,7 @@
 #include <graphene.h>
 #include <cairo.h>
 #include <epoxy/gl.h>
+#include <string.h>
 
 /* Cache eviction strategy
  *
@@ -78,14 +79,7 @@ gsk_gl_glyph_cache_unref (GskGLGlyphCache *self)
 static gboolean
 glyph_cache_equal (gconstpointer v1, gconstpointer v2)
 {
-  const GlyphCacheKey *key1 = v1;
-  const GlyphCacheKey *key2 = v2;
-
-  return key1->font == key2->font &&
-         key1->glyph == key2->glyph &&
-         key1->xshift == key2->xshift &&
-         key1->yshift == key2->yshift &&
-         key1->scale == key2->scale;
+  return memcmp (v1, v2, sizeof (GlyphCacheKey)) == 0;
 }
 
 static guint