diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-09-05 03:58:15 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-09-06 17:11:34 -0400 |
commit | fbc00120222c3d0b048432cd99c06d936bad1d53 (patch) | |
tree | 083455cd211f935cd4a66e71df2651a2116cbd68 /gtk/gtkadjustment.c | |
parent | 3906d21f2f99570850a82ea741fb3b292bb17b31 (diff) | |
download | gtk+-fbc00120222c3d0b048432cd99c06d936bad1d53.tar.gz |
adjustment: Convert to g_object_notify_by_pspec
This avoids pspec lookup overhead in g_object_notify.
Diffstat (limited to 'gtk/gtkadjustment.c')
-rw-r--r-- | gtk/gtkadjustment.c | 105 |
1 files changed, 49 insertions, 56 deletions
diff --git a/gtk/gtkadjustment.c b/gtk/gtkadjustment.c index 2cdad44b0e..4c0f6aff42 100644 --- a/gtk/gtkadjustment.c +++ b/gtk/gtkadjustment.c @@ -71,7 +71,8 @@ enum PROP_UPPER, PROP_STEP_INCREMENT, PROP_PAGE_INCREMENT, - PROP_PAGE_SIZE + PROP_PAGE_SIZE, + NUM_PROPERTIES }; enum @@ -96,6 +97,8 @@ static void gtk_adjustment_dispatch_properties_changed (GObject *object, static guint adjustment_signals[LAST_SIGNAL] = { 0 }; +static GParamSpec *adjustment_props[NUM_PROPERTIES] = { NULL, }; + static guint64 adjustment_changed_stamp = 0; /* protected by global gdk lock */ G_DEFINE_TYPE_WITH_PRIVATE (GtkAdjustment, gtk_adjustment, G_TYPE_INITIALLY_UNOWNED) @@ -134,15 +137,13 @@ gtk_adjustment_class_init (GtkAdjustmentClass *class) * * Since: 2.4 */ - g_object_class_install_property (gobject_class, - PROP_VALUE, - g_param_spec_double ("value", - P_("Value"), - P_("The value of the adjustment"), - -G_MAXDOUBLE, - G_MAXDOUBLE, - 0.0, - GTK_PARAM_READWRITE)); + adjustment_props[PROP_VALUE] = + g_param_spec_double ("value", + P_("Value"), + P_("The value of the adjustment"), + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.0, + GTK_PARAM_READWRITE); /** * GtkAdjustment:lower: @@ -151,15 +152,13 @@ gtk_adjustment_class_init (GtkAdjustmentClass *class) * * Since: 2.4 */ - g_object_class_install_property (gobject_class, - PROP_LOWER, - g_param_spec_double ("lower", - P_("Minimum Value"), - P_("The minimum value of the adjustment"), - -G_MAXDOUBLE, - G_MAXDOUBLE, - 0.0, - GTK_PARAM_READWRITE)); + adjustment_props[PROP_LOWER] = + g_param_spec_double ("lower", + P_("Minimum Value"), + P_("The minimum value of the adjustment"), + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.0, + GTK_PARAM_READWRITE); /** * GtkAdjustment:upper: @@ -171,15 +170,13 @@ gtk_adjustment_class_init (GtkAdjustmentClass *class) * * Since: 2.4 */ - g_object_class_install_property (gobject_class, - PROP_UPPER, - g_param_spec_double ("upper", - P_("Maximum Value"), - P_("The maximum value of the adjustment"), - -G_MAXDOUBLE, - G_MAXDOUBLE, - 0.0, - GTK_PARAM_READWRITE)); + adjustment_props[PROP_UPPER] = + g_param_spec_double ("upper", + P_("Maximum Value"), + P_("The maximum value of the adjustment"), + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.0, + GTK_PARAM_READWRITE); /** * GtkAdjustment:step-increment: @@ -188,15 +185,13 @@ gtk_adjustment_class_init (GtkAdjustmentClass *class) * * Since: 2.4 */ - g_object_class_install_property (gobject_class, - PROP_STEP_INCREMENT, - g_param_spec_double ("step-increment", - P_("Step Increment"), - P_("The step increment of the adjustment"), - -G_MAXDOUBLE, - G_MAXDOUBLE, - 0.0, - GTK_PARAM_READWRITE)); + adjustment_props[PROP_STEP_INCREMENT] = + g_param_spec_double ("step-increment", + P_("Step Increment"), + P_("The step increment of the adjustment"), + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.0, + GTK_PARAM_READWRITE); /** * GtkAdjustment:page-increment: @@ -205,15 +200,13 @@ gtk_adjustment_class_init (GtkAdjustmentClass *class) * * Since: 2.4 */ - g_object_class_install_property (gobject_class, - PROP_PAGE_INCREMENT, - g_param_spec_double ("page-increment", - P_("Page Increment"), - P_("The page increment of the adjustment"), - -G_MAXDOUBLE, - G_MAXDOUBLE, - 0.0, - GTK_PARAM_READWRITE)); + adjustment_props[PROP_PAGE_INCREMENT] = + g_param_spec_double ("page-increment", + P_("Page Increment"), + P_("The page increment of the adjustment"), + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.0, + GTK_PARAM_READWRITE); /** * GtkAdjustment:page-size: @@ -225,15 +218,15 @@ gtk_adjustment_class_init (GtkAdjustmentClass *class) * * Since: 2.4 */ - g_object_class_install_property (gobject_class, - PROP_PAGE_SIZE, - g_param_spec_double ("page-size", - P_("Page Size"), - P_("The page size of the adjustment"), - -G_MAXDOUBLE, - G_MAXDOUBLE, - 0.0, - GTK_PARAM_READWRITE)); + adjustment_props[PROP_PAGE_SIZE] = + g_param_spec_double ("page-size", + P_("Page Size"), + P_("The page size of the adjustment"), + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.0, + GTK_PARAM_READWRITE); + + g_object_class_install_properties (gobject_class, NUM_PROPERTIES, adjustment_props); /** * GtkAdjustment::changed: @@ -354,7 +347,7 @@ static inline void emit_value_changed (GtkAdjustment *adjustment) { g_signal_emit (adjustment, adjustment_signals[VALUE_CHANGED], 0); - g_object_notify (G_OBJECT (adjustment), "value"); + g_object_notify_by_pspec (G_OBJECT (adjustment), adjustment_props[PROP_VALUE]); } static void |