diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2016-12-15 10:55:36 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2017-04-18 12:56:33 +0000 |
commit | df252fc2051a6d2939c77244e74aca4a115d7cce (patch) | |
tree | c3bb9ccfa4affa8cd349004fb75759623b46b7a3 /src | |
parent | e764f345834cfc5052967da100cc26900a97fbb5 (diff) |
Tidy up QDateTimeParser in assorted petty ways
A bit-field was necessarily equal to either zero or its (single-bit)
mask; so comparing to the mask was superfluous.
A local value set and then conditionally over-ridden could easily be
made const by using the condition in a ?: assignment.
A use of qMin() lent itself to turning into a simple conditional
assignment.
Change-Id: I541d98044b23b8c51e6169f617a5841ba8fffc55
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qdatetimeparser.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index d49bec5f76..632ff4c8e7 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -705,7 +705,7 @@ int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionInde state = Invalid; int num = 0; const SectionNode &sn = sectionNode(sectionIndex); - if ((sn.type & Internal) == Internal) { + if (sn.type & Internal) { qWarning("QDateTimeParser::parseSection Internal error (%s %d)", qPrintable(sn.name()), sectionIndex); return -1; @@ -756,11 +756,9 @@ int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionInde if (sn.count >= 3) { QString sectiontext = sectionTextRef.toString(); if (sn.type == MonthSection) { - int min = 1; const QDate minDate = getMinimum().date(); - if (currentValue.date().year() == minDate.year()) { - min = minDate.month(); - } + const int min = (currentValue.date().year() == minDate.year()) + ? minDate.month() : 1; num = findMonth(sectiontext.toLower(), min, sectionIndex, §iontext, &used); } else { num = findDay(sectiontext.toLower(), 1, sectionIndex, §iontext, &used); @@ -1065,8 +1063,8 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos input.replace(sectionPos(sn), sectionSize(i), dayName); } } - } else { - state = qMin(Intermediate, state); + } else if (state > Intermediate) { + state = Intermediate; } } } |