[KPhotoAlbum] Inefficiency in ImageSearchInfo::match()
Jesper K. Pedersen
blackie at kde.org
Tue Sep 11 13:26:21 BST 2012
Ahh x &= y is equal to x = x & y NOT x = x && y;
That can be fixed with rewriting the code to
b = b && trueFunction()
and in the KPA code doing similar. Robert feel free to fix.
Cheers
Jesper.
On Tuesday 11 September 2012 13:58:21 Johannes Zarl wrote:
> On Tuesday 11 September 2012 12:53:57 Jesper K. Pedersen wrote:
> > On Sunday 09 September 2012 20:07:34 Robert Krawitz wrote:
> > > 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.
>
> C++ actually has to evaluate the right side of the code. The arguments of
> the operator&= are evaluated before operator&= is called.
>
> Short example:
>
> cat > test.cpp <<EOF
> #include <iostream>
>
> bool trueFunction()
> {
> std::cout << "trueFunction called." <<std::endl;
> return true;
> }
>
> int main() {
> bool b= false;
> b &= trueFunction();
> std::cout << "b is: " << ( b ? "true" : "false" ) << std::endl;
> return 0;
> }
> EOF
>
> g++ -o test test.cpp
> ./test
> trueFunction called.
> b is: false
>
> Cheers,
> Johannes
--
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