[epiphany] Performance: Set a fixed width on autosized cell renderer
- From: Benjamin Otte <otte src gnome org>
- To: svn-commits-list gnome org
- Subject: [epiphany] Performance: Set a fixed width on autosized cell renderer
- Date: Sun, 12 Jul 2009 18:12:40 +0000 (UTC)
commit 1e8489797a2a5e8d21364e81d8719c3fc800feee
Author: Benjamin Otte <otte gnome org>
Date: Fri Jul 10 14:03:52 2009 +0200
Performance: Set a fixed width on autosized cell renderer
The text cell renderer in use by the url autocompletion is the only
renderer that expands. As the width of the entry completion is known in
advance (as big as the entry you are completing on), we can set a fixed
width. Since the height of the cell renderer is hardcoded, too, the
complete size of the cell renderer is known in advance and Gtk skips
layouting the text to compute the size.
This is a noticable performance improvement, expecially when the
completion contains lots of visible entries.
lib/widgets/ephy-location-entry.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index 5fdd4f0..8a0bd53 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -1225,7 +1225,17 @@ ephy_location_entry_set_completion (EphyLocationEntry *entry,
cell, TRUE);
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (completion),
cell, "text", text_col);
+ /*
+ * As the width of the entry completion is known in advance
+ * (as big as the entry you are completing on), we can set
+ * any fixed width (the 1 is just this random number here).
+ * Since the height is known too, we avoid computing the actual
+ * sizes of the cells, which takes a lot of CPU time and does
+ * not get used anyway.
+ */
+ gtk_cell_renderer_set_fixed_size (cell, 1, -1);
gtk_cell_renderer_text_set_fixed_height_from_font (GTK_CELL_RENDERER_TEXT (cell), 2);
+
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (completion),
cell, textcell_data_func,
entry,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]