From e8f22efe34415db0e1e5cb94635b089b18efe055 Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Tue, 1 Sep 2015 04:42:12 +0200 Subject: XmlNodes are now always closed Remove the close() method and closed attribute. Remove all the calls to close(). (Save one bool per XmlNode, yay, and save a few ifs and some useless function calls. At best it should be unnoticeably faster and lighter and save a few keystrokes in the future) --- louloulibs/xmpp/xmpp_stanza.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'louloulibs/xmpp/xmpp_stanza.cpp') diff --git a/louloulibs/xmpp/xmpp_stanza.cpp b/louloulibs/xmpp/xmpp_stanza.cpp index 01d1d2e..c66b4be 100644 --- a/louloulibs/xmpp/xmpp_stanza.cpp +++ b/louloulibs/xmpp/xmpp_stanza.cpp @@ -84,8 +84,7 @@ std::string xml_unescape(const std::string& data) } XmlNode::XmlNode(const std::string& name, XmlNode* parent): - parent(parent), - closed(false) + parent(parent) { // split the namespace and the name auto n = name.rfind(":"); @@ -191,13 +190,6 @@ XmlNode* XmlNode::get_last_child() const return this->children.back(); } -void XmlNode::close() -{ - if (this->closed) - throw std::runtime_error("Closing an already closed XmlNode"); - this->closed = true; -} - XmlNode* XmlNode::get_parent() const { return this->parent; @@ -219,17 +211,14 @@ std::string XmlNode::to_string() const res += this->name; for (const auto& it: this->attributes) res += " " + it.first + "='" + sanitize(it.second) + "'"; - if (this->closed && !this->has_children() && this->inner.empty()) + if (!this->has_children() && this->inner.empty()) res += "/>"; else { res += ">" + sanitize(this->inner); for (const auto& child: this->children) res += child->to_string(); - if (this->closed) - { - res += "get_name() + ">"; - } + res += "get_name() + ">"; } res += sanitize(this->tail); return res; -- cgit v1.2.3