Slightly optimize Workspace::xStackingOrder
Callgrind analysis showed that this method has room for improvement. The bottle neck is mapping the Unmanaged against the list of windows retreived from xcb_query_tree. The number of windows in that list is rather large (>1000), which turns the loop into an expensive path. Workspace::findUnmanaged seems to be too expensive for that due to the overhead of using a functor and multiple method calls. The Inl. cost before the optimization for checking ~55,000 windows is 2.46. The change uses a good old const-iterator based loop over the unmanaged list to check for the window. This reduces the Incl. cost for checking ~55,000 windows to 0.28. REVIEW: 122067
This commit is contained in:
parent
f643b71902
commit
f7d7c246b8
1 changed files with 14 additions and 3 deletions
17
layers.cpp
17
layers.cpp
|
@ -670,11 +670,22 @@ ToplevelList Workspace::xStackingOrder() const
|
|||
x_stacking.append(c);
|
||||
|
||||
xcb_window_t *windows = tree.children();
|
||||
const auto count = tree->children_len;
|
||||
int foundUnmanagedCount = unmanaged.count();
|
||||
for (unsigned int i = 0;
|
||||
i < tree->children_len;
|
||||
i < count;
|
||||
++i) {
|
||||
if (Unmanaged* c = findUnmanaged(windows[i]))
|
||||
x_stacking.append(c);
|
||||
for (auto it = unmanaged.constBegin(); it != unmanaged.constEnd(); ++it) {
|
||||
Unmanaged *u = *it;
|
||||
if (u->window() == windows[i]) {
|
||||
x_stacking.append(u);
|
||||
foundUnmanagedCount--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundUnmanagedCount == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m_compositor) {
|
||||
const_cast< Workspace* >(this)->m_compositor->checkUnredirect();
|
||||
|
|
Loading…
Reference in a new issue