Don't call IBasicVersionControl::isVersionControlled in a loop
The allVersioned
variable is used only when ctxUrls
contains a single
element.
One call to GitPlugin::isVersionControlled()
takes almost 100 ms. When
the user selects N files in Projects tool view, which are all under Git
version control, and right-clicks on them, this function is called 2*N
times, because VcsPluginHelperPrivate::createMenu()
, which contains the
loop, is called twice. Consequently, KDevelop's UI freezes for 1 second
when the context menu is requested while 5 files are selected, for 4
seconds when 20 files are selected, and for 15 seconds when 80 files are
selected.
With this commit, there is no noticeable UI freeze even if more than 300 files are selected, and the Projects tool view's context menu always appears almost instantly.