Clean up MruWindowTracker |
||
Issue description`MruWindowTracker::BuildMruWindowList()` and `MruWindowTracker::BuildWindowListIgnoreModal()` is called in many different places, sometimes several times per second, e.g. when window is being dragged (while updating shelf visibility). The code can be cleanup and streamlined. For example: - BuildMruWindowList() (and others) `Bind()`s a repeating callback every time it's called to pass the predicate. This is not needed at all. [1] - BuildWindowForCycleList() creates the list, then erases from it, where it could just pass the correct predicate from the beginning. [2] - BuildWindowListInternal() Adds children of the switchable containers from all roots, then invokes the predicates to erase the ones that should be erased. But why add them in the first place? [3] - The algorithm can be changed so that we don't have to reverse anything at the end. [4] - `mru_windows_` is defined as an `std::list<>` [5], which is usually implemented as a doubly-linked list, in which each element node has *at least* [6] two pointers to the previous and next nodes. Being an `std::list<Window*>` (list of pointers) itself, hence our payload (Window*) is one third of the total node size (could be less). So it's a memory inefficient container for this particular use case, not to mention that it's bad for memory locality and doesn't take good advantage of CPU cache. `std::vector<>` is much better in this case. [1]: https://chromium.googlesource.com/chromium/src/+/HEAD/ash/wm/mru_window_tracker.cc#120 [2]: https://chromium.googlesource.com/chromium/src/+/HEAD/ash/wm/mru_window_tracker.cc#129 [3]: https://chromium.googlesource.com/chromium/src/+/HEAD/ash/wm/mru_window_tracker.cc#67 [4]: https://chromium.googlesource.com/chromium/src/+/HEAD/ash/wm/mru_window_tracker.cc#97 [5]: https://chromium.googlesource.com/chromium/src/+/HEAD/ash/wm/mru_window_tracker.h#68 [6]: "At least" since it could be implemented such that the node contains other pointers and tracking elements.
,
Jan 8
|
||
►
Sign in to add a comment |
||
Comment 1 by bugdroid1@chromium.org
, Jan 8