diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-09-22 14:41:38 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-09-30 16:28:42 +0200 |
commit | 158aba25c9878c0790717f1c7e88f2a4f90c96ee (patch) | |
tree | df3eed1e8ecdd5c67104c6667f2d197d55198098 /src/corelib/time/qdatetimeparser_p.h | |
parent | 47cb350d8febf7837b0a7b3cf0eca0036b75a0cb (diff) |
Eliminate QDateTimeParser's mutable parameters at last
I noticed that QDTP has a mutable member, text, which gets set at the
end of each call to parse(); this makes all the in-out parameters
redundant, since relevant methods can simply access - and modify -
text, if it's set *at the start* of parse instaed. (There are no early
returns to complicate matters.) This also makes StateNode::input
redundant.
At the same time, rename the mutable member, as several methods shadow
it with parameter or local variable names; it is too generic.
Change-Id: I2259cd87de5c84201b25c9633d11e59a4a4d57a1
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/time/qdatetimeparser_p.h')
-rw-r--r-- | src/corelib/time/qdatetimeparser_p.h | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/corelib/time/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h index 0cee907ff5..3ad216e176 100644 --- a/src/corelib/time/qdatetimeparser_p.h +++ b/src/corelib/time/qdatetimeparser_p.h @@ -160,7 +160,6 @@ public: 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; @@ -177,7 +176,8 @@ public: LowerCase }; - StateNode parse(QString input, int position, const QDateTime &defaultValue, bool fixup) const; + StateNode parse(const QString &input, int position, + const QDateTime &defaultValue, bool fixup) const; bool fromString(const QString &text, QDate *date, QTime *time) const; bool fromString(const QString &text, QDateTime* datetime) const; bool parseFormat(const QString &format); @@ -193,14 +193,13 @@ public: FieldInfo fieldInfo(int index) const; void setDefaultLocale(const QLocale &loc) { defaultLocale = loc; } - virtual QString displayText() const { return text; } + virtual QString displayText() const { return m_text; } void setCalendar(const QCalendar &calendar); private: int sectionMaxSize(Section s, int count) const; QString sectionText(const QString &text, int sectionIndex, int index) const; - StateNode scanString(const QDateTime &defaultValue, - bool fixup, QString *input) const; + StateNode scanString(const QDateTime &defaultValue, bool fixup) const; struct ParsedSection { int value; int used; @@ -211,8 +210,7 @@ private: : value(ok == Invalid ? -1 : val), used(read), zeroes(zs), state(ok) {} }; - ParsedSection parseSection(const QDateTime ¤tValue, int sectionIndex, - int offset, QString *text) const; + ParsedSection parseSection(const QDateTime ¤tValue, int sectionIndex, int offset) const; int findMonth(const QString &str1, int monthstart, int sectionIndex, int year, QString *monthName = nullptr, int *used = nullptr) const; int findDay(const QString &str1, int intDaystart, int sectionIndex, @@ -286,7 +284,7 @@ protected: // for the benefit of QDateTimeEditPrivate and do not want smaller months (or non-leap years) to alter the day that they chose. */ mutable int cachedDay; - mutable QString text; + mutable QString m_text; QList<SectionNode> sectionNodes; SectionNode first, last, none, popup; QStringList separators; |