diff options
author | Olivier Goffart <olivier.goffart@nokia.com> | 2010-07-26 12:03:00 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-07-26 14:04:18 (GMT) |
commit | a882a46b1c60e5774ade68eaac60922b19a08835 (patch) | |
tree | d603f2ad38e235392e3bccdee51836c2667cfda7 /doc/src/snippets/code/doc_src_containers.qdoc | |
parent | 3a08c5b1682e211bf664c21850187e2b15e89c23 (diff) | |
download | Qt-a882a46b1c60e5774ade68eaac60922b19a08835.zip Qt-a882a46b1c60e5774ade68eaac60922b19a08835.tar.gz Qt-a882a46b1c60e5774ade68eaac60922b19a08835.tar.bz2 |
Doc: use const& in foreach when applicable.
Const reference are slightly faster than doing a copy of the object
on each iteration.
Lead by example by having this pattern right in our documentation
Diffstat (limited to 'doc/src/snippets/code/doc_src_containers.qdoc')
-rw-r--r-- | doc/src/snippets/code/doc_src_containers.qdoc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/doc/src/snippets/code/doc_src_containers.qdoc b/doc/src/snippets/code/doc_src_containers.qdoc index 5cf2aab..1f86f60 100644 --- a/doc/src/snippets/code/doc_src_containers.qdoc +++ b/doc/src/snippets/code/doc_src_containers.qdoc @@ -216,7 +216,7 @@ while (i.hasNext()) //! [17] QLinkedList<QString> list; ... -foreach (QString str, list) +foreach (const QString &str, list) qDebug() << str; //! [17] @@ -224,7 +224,7 @@ foreach (QString str, list) //! [18] QLinkedList<QString> list; ... -foreach (QString str, list) { +foreach (const QString &str, list) { if (str.isEmpty()) break; qDebug() << str; @@ -235,7 +235,7 @@ foreach (QString str, list) { //! [19] QMap<QString, int> map; ... -foreach (QString str, map.keys()) +foreach (const QString &str, map.keys()) qDebug() << str << ":" << map.value(str); //! [19] @@ -243,7 +243,7 @@ foreach (QString str, map.keys()) //! [20] QMultiMap<QString, int> map; ... -foreach (QString str, map.uniqueKeys()) { +foreach (const QString &str, map.uniqueKeys()) { foreach (int i, map.values(str)) qDebug() << str << ":" << i; } |