Iterate over a Container's views once
The number of views in a Container
equals the number of tabs in the
container's split view. Sublime::MainWindow::containers()
returns a list
of all values of its (View
, Container
) map viewContainers
. This list
contains as many duplicate pointers to the same Container
as the number
of views in the container.
Sublime::MainWindow::containers()
is used in 3 places:
KDevelop::MainWindow::updateAllTabColors()
KDevelop::MainWindow::updateTabColor()
KTextEditorIntegration::MainWindow::viewsInSameSplitView()
All 3 callers don't care about the order of containers and don't need duplicate views within each container.
701d2c17 claims to have fixed quadratic
behavior of updateAllTabColors()
. But in fact it replaced cubic behavior
with quadratic one. This commit optimizes quadratic complexity of the 3
callers into linear.
The speedup is measurable when many documents are open or being opened
within a split view. I measured the difference using QElapsedTimer
. A
single call to updateAllTabColors()
took 2923 milliseconds before and 11
milliseconds at this commit with several hundred open documents. This
was in a Debug build of KDevelop, but I expect a significant (if not so
dramatic) speedup in a Release build too.