[KPhotoAlbum] Inefficiency in ImageSearchInfo::match()

Jesper K. Pedersen blackie at kde.org
Tue Sep 11 11:53:57 BST 2012


On Sunday 09 September 2012 20:07:34 Robert Krawitz wrote:
> While coding up the file name match, I noticed that
> ImageSearchInfo::match() doesn't return as soon as it knows that an
> image hasn't matched.  There's a lot of code of the form:
> 
>     bool ok = true;
> #ifdef HAVE_EXIV2
>     ok = _exifSearchInfo.matches( info->fileName() );
> #endif
> ...
>     ok &= ( _label.isEmpty() || info->label().indexOf(_label) != -1 );
> ...
>     return ok;
> 
> 
> Is there any reason it does this rather than simply return if any of
> these tests fail?

I'm 99% sure that &= will not evaluate the right side if the left side already 
is false.

So in effect it does the return right away.

Cheers
-- 
Having trouble finding a given image in your collection containing
thousands of images?

http://www.kphotoalbum.org might be the answer.




More information about the Kphotoalbum mailing list