From 6ffe5f83434e605081eeb2d47dba64f2890ab29d Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Wed, 10 Feb 2010 09:48:46 -0500 Subject: [PATCH] meta_workspace_set_builtin_struts(): optimize out non-changes meta_workspace_set_builtin_struts() is slightly expensive; it involves discarding all our cached computed information about the layout of the workspace. So catch calls to set_builtin_struts() that don't change anything. https://bugzilla.gnome.org/show_bug.cgi?id=609546 --- src/core/workspace.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/core/workspace.c b/src/core/workspace.c index 36d620ffc..5b61af52a 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -959,6 +959,23 @@ ensure_work_areas_validated (MetaWorkspace *workspace) } } +static gboolean +strut_lists_equal (GSList *l, + GSList *m) +{ + for (; l && m; l = l->next, m = m->next) + { + MetaStrut *a = l->data; + MetaStrut *b = m->data; + + if (a->side != b->side || + !meta_rectangle_equal (&a->rect, &b->rect)) + return FALSE; + } + + return l == NULL && m == NULL; +} + /** * meta_workspace_set_builtin_struts: * @workspace: a #MetaWorkspace @@ -972,6 +989,12 @@ void meta_workspace_set_builtin_struts (MetaWorkspace *workspace, GSList *struts) { + /* Reordering doesn't actually matter, so we don't catch all + * no-impact changes, but this is just a (possibly unnecessary + * anyways) optimization */ + if (strut_lists_equal (struts, workspace->builtin_struts)) + return; + workspace_free_builtin_struts (workspace); workspace->builtin_struts = copy_strut_list (struts);