Optimize gdk_x11_screen_supports_net_wm_hint()

Move the call to gdk_x11_atom_to_xatom_for_display() outside of the
search loop in gdk_x11_screen_supports_net_wm_hint().  In my test case
(running Audacious for about a minute), this reduced the total number of
hash table lookups performed from 370,000 to 230,000.

https://bugzilla.gnome.org/show_bug.cgi?id=702913
This commit is contained in:
John Lindgren 2013-06-23 21:22:13 +02:00 committed by Benjamin Otte
parent 1107935d2b
commit 6eea6ddcc3

View File

@ -1470,6 +1470,7 @@ gdk_x11_screen_supports_net_wm_hint (GdkScreen *screen,
GdkX11Screen *x11_screen;
NetWmSupportedAtoms *supported_atoms;
GdkDisplay *display;
Atom atom;
g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
@ -1521,13 +1522,12 @@ gdk_x11_screen_supports_net_wm_hint (GdkScreen *screen,
if (supported_atoms->atoms == NULL)
return FALSE;
i = 0;
while (i < supported_atoms->n_atoms)
{
if (supported_atoms->atoms[i] == gdk_x11_atom_to_xatom_for_display (display, property))
return TRUE;
atom = gdk_x11_atom_to_xatom_for_display (display, property);
++i;
for (i = 0; i < supported_atoms->n_atoms; i++)
{
if (supported_atoms->atoms[i] == atom)
return TRUE;
}
return FALSE;