[gtk: 3/4] snapshot: Preallocate and don't memset the state stack




commit 796e6ee3062dc7d2eae5cb9a48f66a4e84b2992a
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Sep 29 16:03:06 2020 +0200

    snapshot: Preallocate and don't memset the state stack
    
    Most of the time the snapshot is less than 16 levels deep (did some testing
    in gtk-demo), so lets pre-allocate 16 levels of state stack to avoid the
    extra allocation most of the time.

 gtk/gtksnapshot.c | 2 ++
 1 file changed, 2 insertions(+)
---
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c
index ab19aa8ac1..bca48076cd 100644
--- a/gtk/gtksnapshot.c
+++ b/gtk/gtksnapshot.c
@@ -132,6 +132,8 @@ static void gtk_snapshot_state_clear (GtkSnapshotState *state);
 #define GDK_ARRAY_ELEMENT_TYPE GtkSnapshotState
 #define GDK_ARRAY_FREE_FUNC gtk_snapshot_state_clear
 #define GDK_ARRAY_BY_VALUE 1
+#define GDK_ARRAY_PREALLOC 16
+#define GDK_ARRAY_NO_MEMSET 1
 #include "gdk/gdkarrayimpl.c"
 
 /* This is a nasty little hack. We typedef GtkSnapshot to the fake object GdkSnapshot


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