[libdazzle] tree: reduce overhead for expanded icons
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] tree: reduce overhead for expanded icons
- Date: Sat, 22 Jul 2017 06:27:46 +0000 (UTC)
commit 059bbae038c51daa646753dd33714af0980533fc
Author: Christian Hergert <chergert redhat com>
Date: Fri Jul 21 23:27:35 2017 -0700
tree: reduce overhead for expanded icons
This checks for a valid expand icon name before creating a treepath. That
reduces an allocation/free from the common case.
src/tree/dzl-tree.c | 20 +++++++++++---------
1 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/src/tree/dzl-tree.c b/src/tree/dzl-tree.c
index d16c25b..13576e6 100644
--- a/src/tree/dzl-tree.c
+++ b/src/tree/dzl-tree.c
@@ -365,8 +365,7 @@ pixbuf_func (GtkCellLayout *cell_layout,
g_autoptr(DzlTreeNode) node = NULL;
g_autoptr(GIcon) old_icon = NULL;
DzlTree *self = data;
- GtkTreePath *tree_path;
- gboolean expanded;
+ const gchar *expanded_icon_name;
GIcon *icon;
g_assert (GTK_IS_CELL_LAYOUT (cell_layout));
@@ -377,17 +376,20 @@ pixbuf_func (GtkCellLayout *cell_layout,
gtk_tree_model_get (tree_model, iter, 0, &node, -1);
- tree_path = gtk_tree_model_get_path (tree_model, iter);
- expanded = gtk_tree_view_row_expanded (GTK_TREE_VIEW (self), tree_path);
- gtk_tree_path_free (tree_path);
+ expanded_icon_name = _dzl_tree_node_get_expanded_icon (node);
- if (expanded)
+ if (expanded_icon_name != NULL)
{
- const gchar *icon_name = _dzl_tree_node_get_expanded_icon (node);
+ GtkTreePath *tree_path;
+ gboolean expanded;
- if (icon_name != NULL)
+ tree_path = gtk_tree_model_get_path (tree_model, iter);
+ expanded = gtk_tree_view_row_expanded (GTK_TREE_VIEW (self), tree_path);
+ gtk_tree_path_free (tree_path);
+
+ if (expanded)
{
- g_object_set (cell, "icon-name", icon_name, NULL);
+ g_object_set (cell, "icon-name", expanded_icon_name, NULL);
return;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]