summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-02-28 00:11:28 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-28 11:54:52 +0100
commit3518db0bbecd2b10fac714e006f52d66a4f7a992 (patch)
tree95584a394d893aa3fed6167f0d74cc392dcf331d
parentf220f99a6d13a395ca723e9f923b16ef9ac9716b (diff)
QDomNode: don't needlessly call virtual functions
Commit 4dabe78387d10495f9f6d0a7395f2ba3c80432bd changed these functions from virtuals to inlines that check the return value of the remaining virtual function nodeType(). However, two of the functions call nodeType() more than once, which we know will return the same result each time, but requires a compiler with interprocedural optimization capabilities to figure out by itself. So instead of repeatedly calling nodeType(), call it once and store its return value in a temporary, and use the temp for further comparisions. Change-Id: Idbeafb7fd93d275d475218c6df2ad7fdc9162cc5 Reviewed-by: Richard J. Moore <rich@kde.org>
-rw-r--r--src/xml/dom/qdom.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index c16fd03613..0171fc7bef 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -172,14 +172,16 @@ public:
bool isDocumentType() const { return nodeType() == QDomNode::DocumentTypeNode; }
bool isElement() const { return nodeType() == QDomNode::ElementNode; }
bool isEntityReference() const { return nodeType() == QDomNode::EntityReferenceNode; }
- bool isText() const { return (nodeType() == QDomNode::TextNode)
- || (nodeType() == QDomNode::CDATASectionNode); }
+ bool isText() const { const QDomNode::NodeType nt = nodeType();
+ return (nt == QDomNode::TextNode)
+ || (nt == QDomNode::CDATASectionNode); }
bool isEntity() const { return nodeType() == QDomNode::EntityNode; }
bool isNotation() const { return nodeType() == QDomNode::NotationNode; }
bool isProcessingInstruction() const { return nodeType() == QDomNode::ProcessingInstructionNode; }
- bool isCharacterData() const { return (nodeType() == QDomNode::CharacterDataNode)
- || (nodeType() == QDomNode::TextNode)
- || (nodeType() == QDomNode::CommentNode); }
+ bool isCharacterData() const { const QDomNode::NodeType nt = nodeType();
+ return (nt == QDomNode::CharacterDataNode)
+ || (nt == QDomNode::TextNode)
+ || (nt == QDomNode::CommentNode); }
bool isComment() const { return nodeType() == QDomNode::CommentNode; }
virtual QDomNode::NodeType nodeType() const { return QDomNode::BaseNode; }