From 88fd9a281a1be2563124fa67f43950edf08eb5f0 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 25 Jan 2022 21:10:32 +0100 Subject: [PATCH] QFlatMap: avoid post-(in|de)crement on iterators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generic code needs to avoid post-increment and -decrement, because they're less efficient than pre-increment and -decrement when implemented in class types as opposed to scalars (extra copy necessary). Use the common pattern of implementing post- using pre-increment. Pick-to: 6.3 Change-Id: Ida38df04c6c6f877453e5b3a1983457cc7f63f11 Reviewed-by: Jörg Bornemann Reviewed-by: Edward Welbourne --- src/corelib/tools/qflatmap_p.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qflatmap_p.h b/src/corelib/tools/qflatmap_p.h index ea942a0283c..17c6167ddf3 100644 --- a/src/corelib/tools/qflatmap_p.h +++ b/src/corelib/tools/qflatmap_p.h @@ -191,7 +191,7 @@ public: { iterator r = *this; - i++; + ++*this; return r; } @@ -204,7 +204,7 @@ public: iterator operator--(int) { iterator r = *this; - i--; + --*this; return r; } @@ -328,7 +328,7 @@ public: { const_iterator r = *this; - i++; + ++*this; return r; } @@ -341,7 +341,7 @@ public: const_iterator operator--(int) { const_iterator r = *this; - i--; + --*this; return r; }