diff options
author | Robin Burchell <robin.burchell@collabora.co.uk> | 2010-04-26 12:36:58 (GMT) |
---|---|---|
committer | Andreas Kling <andreas.kling@nokia.com> | 2010-04-26 12:41:59 (GMT) |
commit | 1c1f655d82e4af2ff98970472f687e55216e9fcf (patch) | |
tree | 26082734dd73ca33352340a78584fb32903facd7 /src | |
parent | 9e46d92af90ed6fb5b98a1a043f7564ec1e67a94 (diff) | |
download | Qt-1c1f655d82e4af2ff98970472f687e55216e9fcf.zip Qt-1c1f655d82e4af2ff98970472f687e55216e9fcf.tar.gz Qt-1c1f655d82e4af2ff98970472f687e55216e9fcf.tar.bz2 |
Don't use QList's begin() and end() where possible.
This avoids an unnecessary iterator creation, which can speed up some cases.
Merge-request: 2371
Reviewed-by: Andreas Kling <andreas.kling@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qlist.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 67f63f3..722744c 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -267,9 +267,9 @@ public: inline int count() const { return p.size(); } inline int length() const { return p.size(); } // Same as count() inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); } - inline const T& first() const { Q_ASSERT(!isEmpty()); return *begin(); } + inline const T& first() const { Q_ASSERT(!isEmpty()); return at(0); } T& last() { Q_ASSERT(!isEmpty()); return *(--end()); } - const T& last() const { Q_ASSERT(!isEmpty()); return *(--end()); } + const T& last() const { Q_ASSERT(!isEmpty()); return at(count() - 1); } inline void removeFirst() { Q_ASSERT(!isEmpty()); erase(begin()); } inline void removeLast() { Q_ASSERT(!isEmpty()); erase(--end()); } inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; } |