From 55a88206f3114eb13c9b1a26279a31a1838bbd94 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 28 Jan 2022 01:26:40 +0100 Subject: [PATCH] QCalendar: eradicate Java-style iterator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We had QT_NO_JAVA_STYLE_ITERATORS in .qmake.conf, but it was lost in the transition from QMake to CMake, and - plop - they start trickling in again. Pick-to: 6.3 6.2 Change-Id: Ib92937e5fe510aba2aad92809f7a6d5fbae6f3a0 Reviewed-by: Alexey Edelev Reviewed-by: Edward Welbourne Reviewed-by: Qt CI Bot Reviewed-by: Jörg Bornemann --- src/corelib/time/qcalendar.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/corelib/time/qcalendar.cpp b/src/corelib/time/qcalendar.cpp index adefa99ee9..5d0b55ad89 100644 --- a/src/corelib/time/qcalendar.cpp +++ b/src/corelib/time/qcalendar.cpp @@ -449,10 +449,15 @@ const QCalendarBackend *QCalendarRegistry::fromEnum(QCalendar::System system) QStringList QCalendarRegistry::backendNames(const QCalendarBackend *backend) { QStringList l; + l.reserve(byName.size()); // too large, but never really large, so ok - QHashIterator i(byName); - while (i.findNext(const_cast(backend))) - l.push_back(i.key()); + // same as byName.keys(backend), except for + // - the missing const on mapped_type and + // - CalendarName != QString as the key_type + for (auto it = byName.cbegin(), end = byName.cend(); it != end; ++it) { + if (it.value() == backend) + l.push_back(it.key()); + } return l; }