Pass QDateTimeParser::SectionNode by value, not const ref

It's trivially copyable and fits into a (128-bit) register.
Delete one spurious line from a \internal doc in the process.

Task-number: QTBUG-122619
Change-Id: I55bd39f176f58e0dcd0ecc86e88bd29d449c7fd7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Edward Welbourne 2024-04-10 15:53:13 +02:00
parent 33cc653288
commit 5a09ade176
4 changed files with 6 additions and 8 deletions

View File

@ -334,7 +334,7 @@ int QDateTimeParser::sectionPos(int sectionIndex) const
return sectionPos(sectionNode(sectionIndex));
}
int QDateTimeParser::sectionPos(const SectionNode &sn) const
int QDateTimeParser::sectionPos(SectionNode sn) const
{
switch (sn.type) {
case FirstSection: return 0;
@ -2314,11 +2314,9 @@ QString QDateTimeParser::getAmPmText(AmPm ap, Case cs) const
/*
\internal
I give arg2 preference because arg1 is always a QDateTime.
*/
bool operator==(const QDateTimeParser::SectionNode &s1, const QDateTimeParser::SectionNode &s2)
bool operator==(QDateTimeParser::SectionNode s1, QDateTimeParser::SectionNode s2)
{
return (s1.type == s2.type) && (s1.pos == s2.pos) && (s1.count == s2.count);
}

View File

@ -212,7 +212,7 @@ protected: // for the benefit of QDateTimeEditPrivate
int sectionSize(int index) const;
int sectionMaxSize(int index) const;
int sectionPos(int index) const;
int sectionPos(const SectionNode &sn) const;
int sectionPos(SectionNode sn) const;
const SectionNode &sectionNode(int index) const;
Section sectionType(int index) const;
@ -265,7 +265,7 @@ protected: // for the benefit of QDateTimeEditPrivate
};
Q_DECLARE_TYPEINFO(QDateTimeParser::SectionNode, Q_PRIMITIVE_TYPE);
Q_CORE_EXPORT bool operator==(const QDateTimeParser::SectionNode &s1, const QDateTimeParser::SectionNode &s2);
Q_CORE_EXPORT bool operator==(QDateTimeParser::SectionNode s1, QDateTimeParser::SectionNode s2);
Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeParser::Sections)
Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeParser::FieldInfo)

View File

@ -2478,7 +2478,7 @@ int QDateTimeEditPrivate::absoluteIndex(QDateTimeEdit::Section s, int index) con
return NoSectionIndex;
}
int QDateTimeEditPrivate::absoluteIndex(const SectionNode &s) const
int QDateTimeEditPrivate::absoluteIndex(SectionNode s) const
{
return sectionNodes.indexOf(s);
}

View File

@ -67,7 +67,7 @@ public:
int cursorPosition() const override { return edit ? edit->cursorPosition() : -1; }
int absoluteIndex(QDateTimeEdit::Section s, int index) const;
int absoluteIndex(const SectionNode &s) const;
int absoluteIndex(SectionNode s) const;
QDateTime stepBy(int index, int steps, bool test = false) const;
int sectionAt(int pos) const;
int closestSection(int index, bool forward) const;