summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-12-06 18:30:55 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-12-07 06:27:07 +0000
commit2a887a517eaaa2c5324aecf3b919899b7a86ff4a (patch)
tree0f6d1a7618ac13e9a448dda41388d38ff67b4a82
parent61f92c0bcedfaad1721bd1c985217c5271e9086c (diff)
QCalendar: Optimize std::vector accessv5.14.0-rc2v5.14.0
As we assert on the size of the vector before accessing it, there is no point in using the checked at() method over operator[]. Besides, if at() throws, what are we going to do with the exception anyway. Incidentally, this also works around a compiler bug causing binary incompatibility in QtQml. Change-Id: I460e7514429daecabc304eb2c5f96ed715008b0a Fixes: QTBUG-80535 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/corelib/time/qcalendar.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/time/qcalendar.cpp b/src/corelib/time/qcalendar.cpp
index d308aeba2b..6a4623ce92 100644
--- a/src/corelib/time/qcalendar.cpp
+++ b/src/corelib/time/qcalendar.cpp
@@ -100,7 +100,7 @@ struct Registry {
if (id == QCalendar::System::User) {
byId.push_back(calendar);
} else {
- Q_ASSERT(byId.at(size_t(id)) == nullptr);
+ Q_ASSERT(byId[size_t(id)] == nullptr);
byId[size_t(id)] = calendar;
}
if (id == QCalendar::System::Gregorian) {
@@ -618,7 +618,7 @@ const QCalendarBackend *QCalendarBackend::fromEnum(QCalendar::System system)
if (calendarRegistry.isDestroyed() || system == QCalendar::System::User)
return nullptr;
Q_ASSERT(calendarRegistry->byId.size() >= size_t(system));
- if (auto *c = calendarRegistry->byId.at(size_t(system)))
+ if (auto *c = calendarRegistry->byId[size_t(system)])
return c;
switch (system) {
case QCalendar::System::Gregorian: