diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2016-12-15 10:55:43 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2017-06-20 09:54:35 +0000 |
commit | 0fdbd239c0504f3f7a7659261bae1cbb10c2bb06 (patch) | |
tree | deec2a40ed1f0c90577d4bcdb84f4f9df0e99542 /src/corelib/tools/qdatetimeparser_p.h | |
parent | 3fe9e5dff79590c79bc56cdee6a115d5cf6b3319 (diff) |
QDateTimeParser: partial break-up of long method to eliminate goto
Method parse() was very long, had an inner block purely to isolate
many variables and had a clean-up block at the end to which it would
goto from within that 300-line block. Split out that block as a
separate function, turn goto into premature return, clean up the
result.
Change-Id: I63ded0c0afacf4a1972a3a62c2d81834950ab729
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qdatetimeparser_p.h')
-rw-r--r-- | src/corelib/tools/qdatetimeparser_p.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h index 3a97b9d468..ecacf3429c 100644 --- a/src/corelib/tools/qdatetimeparser_p.h +++ b/src/corelib/tools/qdatetimeparser_p.h @@ -160,11 +160,14 @@ public: }; struct StateNode { - StateNode() : state(Invalid), conflicts(false) {} + StateNode() : state(Invalid), padded(0), conflicts(false) {} + StateNode(const QDateTime &val, State ok=Acceptable, int pad=0, bool bad=false) + : value(val), state(ok), padded(pad), conflicts(bad) {} QString input; + QDateTime value; State state; + int padded; bool conflicts; - QDateTime value; }; enum AmPm { @@ -200,6 +203,8 @@ private: int sectionMaxSize(Section s, int count) const; QString sectionText(const QString &text, int sectionIndex, int index) const; #ifndef QT_NO_DATESTRING + StateNode scanString(const QDateTime &defaultValue, + bool fixup, QString *input) const; struct ParsedSection { int value; int used; |