summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2019-12-19 18:56:48 +0100
committerPaul Wicking <paul.wicking@qt.io>2020-01-06 06:17:04 +0100
commita18457ab5310b60290b4655f51aec859e7b3bc8a (patch)
tree4f085e503c35238cd007e2aed0808a7ba9fc8470
parent3c2523b24220aefa4f3335f11fd8eb7993f29160 (diff)
downloadqttools-a18457ab5310b60290b4655f51aec859e7b3bc8a.tar.gz
QDoc: clean up ctor/dtor in Atom
* Make calling code specify Atom type, remove superfluous ctor. * Move default initialization from initialization list to in-class for member that initializes the same in all ctors. * Move initialization from ctor body to initialization list. * Mark trivial dtor default. Change-Id: I5e4a9e5cdcf0b9f3ba68b53dcab34c2ab77b415d Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r--src/qdoc/atom.cpp2
-rw-r--r--src/qdoc/atom.h22
-rw-r--r--src/qdoc/doc.cpp4
3 files changed, 10 insertions, 18 deletions
diff --git a/src/qdoc/atom.cpp b/src/qdoc/atom.cpp
index 298d2bbd4..f4920f43e 100644
--- a/src/qdoc/atom.cpp
+++ b/src/qdoc/atom.cpp
@@ -377,7 +377,7 @@ void Atom::dump() const
the space character.
*/
LinkAtom::LinkAtom(const QString &p1, const QString &p2)
- : Atom(p1),
+ : Atom(Atom::Link, p1),
resolved_(false),
genus_(Node::DontCare),
goal_(Node::NoType),
diff --git a/src/qdoc/atom.h b/src/qdoc/atom.h
index f7cb0b654..6b37618e8 100644
--- a/src/qdoc/atom.h
+++ b/src/qdoc/atom.h
@@ -134,37 +134,29 @@ public:
friend class LinkAtom;
- Atom(const QString &string) : next_(nullptr), type_(Link) { strs << string; }
+ Atom(AtomType type, const QString &string = "") : type_(type), strs(string) {}
- Atom(AtomType type, const QString &string = "") : next_(nullptr), type_(type)
+ Atom(AtomType type, const QString &p1, const QString &p2) : type_(type), strs(p1)
{
- strs << string;
- }
-
- Atom(AtomType type, const QString &p1, const QString &p2) : next_(nullptr), type_(type)
- {
- strs << p1;
if (!p2.isEmpty())
strs << p2;
}
- Atom(Atom *previous, AtomType type, const QString &string = "")
- : next_(previous->next_), type_(type)
+ Atom(Atom *previous, AtomType type, const QString &string)
+ : next_(previous->next_), type_(type), strs(string)
{
- strs << string;
previous->next_ = this;
}
Atom(Atom *previous, AtomType type, const QString &p1, const QString &p2)
- : next_(previous->next_), type_(type)
+ : next_(previous->next_), type_(type), strs(p1)
{
- strs << p1;
if (!p2.isEmpty())
strs << p2;
previous->next_ = this;
}
- virtual ~Atom() {}
+ virtual ~Atom() = default;
void appendChar(QChar ch) { strs[0] += ch; }
void appendString(const QString &string) { strs[0] += string; }
@@ -194,7 +186,7 @@ public:
protected:
static QString noError_;
- Atom *next_;
+ Atom *next_ = nullptr;
AtomType type_;
QStringList strs;
};
diff --git a/src/qdoc/doc.cpp b/src/qdoc/doc.cpp
index 0d5d059d6..89748b0ad 100644
--- a/src/qdoc/doc.cpp
+++ b/src/qdoc/doc.cpp
@@ -1860,7 +1860,7 @@ void DocParser::append(const QString &string)
Atom::AtomType lastType = priv->text.lastAtom()->type();
if ((lastType == Atom::Code) && priv->text.lastAtom()->string().endsWith(QLatin1String("\n\n")))
priv->text.lastAtom()->chopString();
- priv->text << Atom(string); // The Atom type is Link.
+ priv->text << Atom(Atom::Link, string);
}
void DocParser::append(Atom::AtomType type, const QString &p1, const QString &p2)
@@ -1877,7 +1877,7 @@ void DocParser::append(const QString &p1, const QString &p2)
if ((lastType == Atom::Code) && priv->text.lastAtom()->string().endsWith(QLatin1String("\n\n")))
priv->text.lastAtom()->chopString();
if (p2.isEmpty())
- priv->text << Atom(p1); // The Atom type is Link.
+ priv->text << Atom(Atom::Link, p1);
else
priv->text << LinkAtom(p1, p2);
}