[mythtv] Possible errors

Jason Hoos jhoos at thwack.net
Fri Oct 8 20:13:55 UTC 2004


On Fri, 2004-10-08 at 12:58, marty.boeckman at comcast.net wrote:
> The code below has a note about being slow. It could be fixed by putting a break statement in the loop whenever the boolean is set to false.  Because once the boolean is set to false, that's all this method can ever return.  I found this potential issue using a case tools audit feature. The results of the audit are posted at: http://home.comcast.net/~marty.boeckman/audit.txt
> 
> bool GenericTree::checkNode(QValueList<int> route_of_branches)
> {
>     bool found_it = true;
>     GenericTree *parent_finder = this;
> 
>     // FIXME: slow
> 
>     for (int i = route_of_branches.count() - 1; i > -1 && found_it; --i)
>     {
>         if (!(parent_finder->getInt() == (*route_of_branches.at(i))))
>             found_it = false;
<snip>

Actually, the way the loop above is written it already will exit
immediately when found_it is false, as part of the "i > -1 && found_it"
clause in the for loop, so adding break statements wouldn't really gain
much except possibly avoiding the second if statement...





More information about the mythtv-dev mailing list