[gtk/wip/chergert/glproto: 620/920] only do one memset




commit ba533c09e789324f83aa6891fc41a82953f5d481
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jan 1 21:48:22 2021 -0800

    only do one memset

 gsk/next/gskgluniformstate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gsk/next/gskgluniformstate.c b/gsk/next/gskgluniformstate.c
index 5c64e790c7..1328402c77 100644
--- a/gsk/next/gskgluniformstate.c
+++ b/gsk/next/gskgluniformstate.c
@@ -136,6 +136,7 @@ alloc_uniform_data (GByteArray *buffer,
 {
   guint align = size > 4 ? GLIB_SIZEOF_VOID_P : 4;
   guint masked = buffer->len & (align - 1);
+  guint old_len = buffer->len;
 
   /* Try to give a more natural alignment based on the size
    * of the uniform. In case it's greater than 4 try to at least
@@ -146,12 +147,11 @@ alloc_uniform_data (GByteArray *buffer,
     {
       guint prefix_align = align - masked;
       g_byte_array_set_size (buffer, buffer->len + prefix_align);
-      memset (buffer->data + buffer->len - prefix_align, 0, prefix_align);
     }
 
   *offset = buffer->len;
   g_byte_array_set_size (buffer, buffer->len + size);
-  memset (buffer->data + buffer->len - size, 0, size);
+  memset (buffer->data + old_len, 0, buffer->len - old_len);
 
   g_assert ((*offset & (align - 1)) == 0);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]