diff options
author | Alejandro Exojo <suy@badopi.org> | 2013-12-13 11:28:59 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-17 09:11:49 +0100 |
commit | be29c4053e00f80964a1a997111d89e7a96adb7d (patch) | |
tree | 4967df7f5379335b130b2be88d2d9e680feb91d5 /src/corelib/doc/src | |
parent | e1804dcf3d099826493e553e870e4fd613266709 (diff) |
Clarify foreach's documentation on valued-containers
- Explain that values() is unnecessary and causes an extra copy.
- Replace "are fastest" with "are faster".
- Briefly explain the snippet.
Change-Id: Iff1d3a0b6140fca1d78157aeeca3d538c4d78b84
Reviewed-by: Albert Astals Cid <albert.astals@canonical.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/doc/src')
-rw-r--r-- | src/corelib/doc/src/containers.qdoc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc index fa26409d83..6017269272 100644 --- a/src/corelib/doc/src/containers.qdoc +++ b/src/corelib/doc/src/containers.qdoc @@ -578,9 +578,11 @@ \snippet code/doc_src_containers.cpp 18 With QMap and QHash, \c foreach accesses the value component of - the (key, value) pairs. If you want to iterate over both the keys - and the values, you can use iterators (which are fastest), or you - can write code like this: + the (key, value) pairs automatically, so you should not call + values() on the container (it would generate an unnecessary copy, + see below). If you want to iterate over both the keys and the + values, you can use iterators (which are faster), or you can + obtain the keys, and use them to get the values too: \snippet code/doc_src_containers.cpp 19 |