The call to windowType is quite in the hot code path of KWin and not really well implemented. It performs two dynamic casts just to figure out whether it's a Client or Unmanaged and has basically two different implementations interwoven in this method. Making it a pure virtual method should quite improve the readability and performance of this method.
Git commit 700bccde695f6747626295db7cba5e741a108684 by Martin Gräßlin. Committed on 06/09/2012 at 09:09. Pushed by graesslin into branch 'master'. Toplevel::windowType becomes a pure virtual function The method windowType needs actually two implementations: * one for Clients * one for Unmanaged as for Clients also the window rules are checked and hacks are applied which is both not needed for Unmanaged windows. To have the Client specific behavior in windowType the function used to perform two dynamic_casts which made this method one of the most expensive during compositing, e.g. for ~1000 frames * called ~43000 times * ~85000 dynamic casts * incl. cost of method: 0.24 * self cost of method: 0.05 * incl. cost of the casts: 0.12 After the change to remove the dynamic casts we have for ~1500 frames in Client::windowType: * called ~31000 times * incl. cost of 0.06 * self cost of 0.02 Calls on Unmanaged and Deleted are so low that we do not need to consider them. FIXED-IN: 4.10 REVIEW: 106349 M +21 -0 kwin/client.cpp M +1 -0 kwin/client.h M +10 -0 kwin/deleted.cpp M +1 -0 kwin/deleted.h M +0 -20 kwin/toplevel.cpp M +1 -1 kwin/toplevel.h M +11 -0 kwin/unmanaged.cpp M +1 -0 kwin/unmanaged.h http://commits.kde.org/kde-workspace/700bccde695f6747626295db7cba5e741a108684