[gtk/wip/chergert/glproto] next: add comment regarding linked list



commit 0c9245f6de77dec6aaf3ed3067a3a19e2f4b390d
Author: Christian Hergert <chergert redhat com>
Date:   Tue Feb 23 11:43:56 2021 -0800

    next: add comment regarding linked list

 gsk/next/gskglcommandqueue.c | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/gsk/next/gskglcommandqueue.c b/gsk/next/gskglcommandqueue.c
index eb36276f3d..a61109bfc6 100644
--- a/gsk/next/gskglcommandqueue.c
+++ b/gsk/next/gskglcommandqueue.c
@@ -489,6 +489,13 @@ enqueue_batch (GskGLCommandQueue *self)
   g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
   g_assert (self->batches.len > 0);
 
+  /* Batches are linked lists but using indexes into the batches array instead
+   * of pointers. This is for two main reasons. First, 16-bit indexes allow us
+   * to store the information in 4 bytes, where as two pointers would take 16
+   * bytes.  Furthermore, we have an array here so pointers would get
+   * invalidated if we realloc()'d (and that can happen from time to time).
+   */
+
   index = self->batches.len - 1;
 
   if (self->head_batch_index == -1)


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