[Qt-interest] What is the best, "for" or "foreach"?
Gordon Schumacher
gordon at rebit.com
Wed Dec 9 21:44:56 CET 2009
-----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.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAksgDEgACgkQ2yRp4mXKHF2+pgCgtc9kKbROf3oUB7+QlTYxBAQ6
dDoAn0YcoHTON78R4Xvao/3osWyLBtLE
=c5NT
-----END PGP SIGNATURE-----
More information about the Qt-interest-old
mailing list