[KPhotoAlbum] Search performance (at least) linear in number of search terms?

Tobias Leupold tobias.leupold at gmx.de
Sun Jul 16 09:53:37 CEST 2017

Hi :-)

As far as I can grasp it, Set.h and Set.cpp is a remnant of KPA using older Qt 
versions which did not provide the needed functionality.

In case of doubt, Johannes is the one to decide whether or not, but I think 
this can be removed in favor of using Qt directly. Which does not only – as 
you stated – speed up the code, but also simplify it.

Cheers, Tobias

E-Mail vom 15.07.2017, 23:34 von Robert Krawitz:
> Well, I did find one piece of really low hanging fruit: the overlap
> function (which, mind you, is used in only one place, so Set.cpp and
> Set.h might just as well be removed altogether) was computing the
> intersection of the two sets of strings rather than just determining
> whether there is an intersection.
> For my test case, it cut the time from about 18 seconds to maybe 13.
> While with only 222,000 images and searching for about 40 tags it
> should be able to do a lot better indeed than that, this is at least a
> start in the right direction.
> If you want, I'll do a patch that removes Set.h and Set.cpp altogether.
> diff --git a/DB/ImageInfo.cpp b/DB/ImageInfo.cpp
> index d5b8cb25..c5897fe7 100644
> --- a/DB/ImageInfo.cpp
> +++ b/DB/ImageInfo.cpp
> @@ -132,7 +132,7 @@ bool ImageInfo::hasCategoryInfo( const QString& key,
> const QString& value ) cons
>  bool DB::ImageInfo::hasCategoryInfo( const QString& key, const StringSet&
> values ) const {
> -    return Utilities::overlap( m_categoryInfomation[key], values );
> +    return values.intersects( m_categoryInfomation[key] );
>  }

More information about the KPhotoAlbum mailing list