-
Agata Cacko authored
Before this commit, to get the tags for the resources, Krita would, for every resource separately, set the resource id to the filterproxy model and then iterate on that model to get the tags. This is inefficient because the filter proxy model iterates on all the items in the original model to get the matching rows anyway. This commit ensures that the model has all the resource ids at once, so the iterating over the base model rows happens only twice (one to filter out inside the proxy model, one to iterate on the rows to build the tags list). NOTE: Setting of the resource ids happens only in setResourceIds() function, and updateView() assumes it's already done. This improves the performance even more (because every setResourcesFilter() invalidates the filter inside the model, which causes it to iterate and filter out incorrect rows again, while having the filter already done means that adding or removing on those resources will only add or remove some rows), but the performance imrpovements are only on doing repeated actions on the same set of resources. It can potentially make it a bit more error prone, hence the comment above the loop. A possibility to make it still faster than before this commit, but less error prone: just set resources filter just before the loop, or set it to empty list and check for resource id being in the selected list manually in updateView(). --- Credit for Grum999 for the idea and noticing the problem.
983ea2ac