[Qt-interest] What is the best, "for" or "foreach"?
M. Bashir Al-Noimi
mbnoimi at gmx.com
Thu Dec 10 00:57:53 CET 2009
On 09/12/2009 10:44 م, Gordon Schumacher wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> M. Bashir Al-Noimi wrote:
>
>> Sean and Paul, your discussion is truly useful thanks for you ;-)
>>
>> By the result I think using "for" with "QList" in classic usage is
>> more safe because it gives us same performance in most cases.
>>
> I would suggest two things:
> 1) Use myList.at(i) instead of list[i] - the former is guaranteed
> const, while the latter "might" be depending on your compiler.
> 2) As noted previously, use a const ref instead of a non-const one.
>
> I would expect that for that comparison you should see identical results.
>
Thanks :-P
--
Best Regards
Muhammad Bashir Al-Noimi
My Blog: http://mbnoimi.net
More information about the Qt-interest-old
mailing list