[Kst] kdeextragear-2/kst/kst/datasources/ascii

George Staikos staikos at kde.org
Tue Apr 5 05:36:27 CEST 2005


On Monday 04 April 2005 23:20, Matthew D Truch wrote:
> > --- kdeextragear-2/kst/kst/datasources/ascii/ascii.cpp  #1.37:1.38
> > @@ -261,5 +261,5 @@ bool AsciiSource::isValidField(const QSt
> >    field.toUInt(&ok);
> >
> > -  return ok;
> > +  return ok && fieldList().contains(field);
> >  }
>
> Doesn't && short-circuit left to right, so the
> fieldList().contains(field) will never be executed, or does return
> 'return' false?

   Right.  If ok is false, then the field is not a number so we should just 
fail and not bother generating the fieldList.  Actually toUInt() is a bit of 
a redundant check, but it doesn't hurt much.

   If the code was:


   return fieldList().contains(field) && ok;

   then it would generate fieldList() and do a search even if "ok" is false, 
which means it was going to fail to begin with.  That's why it is the order 
that I wrote it in.

   Thanks for reviewing though!

-- 
George Staikos
KDE Developer				http://www.kde.org/
Staikos Computing Services Inc.		http://www.staikos.net/


More information about the Kst mailing list