QCalendar: Optimize std::vector access

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>
bb10
Ulf Hermann 2019-12-06 18:30:55 +01:00
parent 61f92c0bce
commit 2a887a517e
1 changed files with 2 additions and 2 deletions

View File

@ -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: