[gtk+/wip/css-optimize2: 3/10] css: Start array allocation with a better size



commit 39d94a73e33372cd374292b83149c7593fee1e46
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Dec 3 14:29:40 2012 +0100

    css: Start array allocation with a better size
    
    All computed values will compute all normal properties at least, so
    we might as well allocate these upfront, which leads to a lot less
    reallocations.

 gtk/gtkcsscomputedvalues.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcsscomputedvalues.c b/gtk/gtkcsscomputedvalues.c
index f5f515a..dea23bd 100644
--- a/gtk/gtkcsscomputedvalues.c
+++ b/gtk/gtkcsscomputedvalues.c
@@ -179,7 +179,8 @@ _gtk_css_computed_values_set_value (GtkCssComputedValues *values,
   gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
 
   if (values->values == NULL)
-    values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
+    values->values = g_ptr_array_new_full (_gtk_css_style_property_get_n_properties (),
+					   (GDestroyNotify)_gtk_css_value_unref);
   if (id >= values->values->len)
    g_ptr_array_set_size (values->values, id + 1);
 



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