From 193c28a4a3b4d52be169c6664cea8efb112aa66d Mon Sep 17 00:00:00 2001
From: Alberto Massari <amassari@apache.org>
Date: Tue, 20 Dec 2005 13:53:44 +0000
Subject: [PATCH] Removed unnecessary casts inside DOMNodeList

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@357990 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/dom/impl/DOMNodeListImpl.cpp | 6 +++---
 src/xercesc/dom/impl/DOMNodeListImpl.hpp | 6 +++---
 src/xercesc/dom/impl/DOMParentNode.cpp   | 5 ++---
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/xercesc/dom/impl/DOMNodeListImpl.cpp b/src/xercesc/dom/impl/DOMNodeListImpl.cpp
index 5b2f1c2cf..f97ddd703 100644
--- a/src/xercesc/dom/impl/DOMNodeListImpl.cpp
+++ b/src/xercesc/dom/impl/DOMNodeListImpl.cpp
@@ -30,7 +30,7 @@ XERCES_CPP_NAMESPACE_BEGIN
 //   this implementation is too stupid - needs a cache of some kind.
 //
 
-DOMNodeListImpl::DOMNodeListImpl(DOMNode *node)
+DOMNodeListImpl::DOMNodeListImpl(DOMParentNode *node)
 :   fNode(node)
 {
 }
@@ -45,7 +45,7 @@ DOMNodeListImpl:: ~DOMNodeListImpl()
 XMLSize_t DOMNodeListImpl::getLength() const{
     XMLSize_t count = 0;
     if (fNode) {
-        DOMNode *node = castToParentImpl(fNode)->fFirstChild;
+        DOMNode *node = fNode->fFirstChild;
         while(node != 0){
             ++count;
             node = castToChildImpl(node)->nextSibling;
@@ -59,7 +59,7 @@ XMLSize_t DOMNodeListImpl::getLength() const{
 
 DOMNode *DOMNodeListImpl::item(XMLSize_t index) const{
     if (fNode) {
-        DOMNode *node = castToParentImpl(fNode)->fFirstChild;
+        DOMNode *node = fNode->fFirstChild;
         for(XMLSize_t i=0; i<index && node!=0; ++i)
             node = castToChildImpl(node)->nextSibling;
         return node;
diff --git a/src/xercesc/dom/impl/DOMNodeListImpl.hpp b/src/xercesc/dom/impl/DOMNodeListImpl.hpp
index 7446ac980..7b28a26ec 100644
--- a/src/xercesc/dom/impl/DOMNodeListImpl.hpp
+++ b/src/xercesc/dom/impl/DOMNodeListImpl.hpp
@@ -45,13 +45,13 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
-
+class DOMParentNode;
 class DOMNode;
 
 class CDOM_EXPORT DOMNodeListImpl: public DOMNodeList
 {
 private:
-    DOMNode   *fNode;
+    DOMParentNode   *fNode;
 
     // Unused, and unimplemented constructors, operators, etc.
     DOMNodeListImpl();
@@ -59,7 +59,7 @@ private:
     DOMNodeListImpl & operator = (const DOMNodeListImpl & other);
 
 public:
-    DOMNodeListImpl(DOMNode *node);
+    DOMNodeListImpl(DOMParentNode *node);
     virtual             ~DOMNodeListImpl();
     virtual DOMNode *  item(XMLSize_t index) const;
     virtual XMLSize_t getLength() const;
diff --git a/src/xercesc/dom/impl/DOMParentNode.cpp b/src/xercesc/dom/impl/DOMParentNode.cpp
index 3d1a976e6..ece85adae 100644
--- a/src/xercesc/dom/impl/DOMParentNode.cpp
+++ b/src/xercesc/dom/impl/DOMParentNode.cpp
@@ -23,7 +23,6 @@
 #include <xercesc/dom/DOMNode.hpp>
 
 #include "DOMDocumentImpl.hpp"
-#include "DOMNodeListImpl.hpp"
 #include "DOMRangeImpl.hpp"
 #include "DOMNodeIteratorImpl.hpp"
 #include "DOMParentNode.hpp"
@@ -32,14 +31,14 @@
 XERCES_CPP_NAMESPACE_BEGIN
 
 DOMParentNode::DOMParentNode(DOMDocument *ownerDoc)
-    : fOwnerDocument(ownerDoc), fFirstChild(0), fChildNodeList(castToNode(this))
+    : fOwnerDocument(ownerDoc), fFirstChild(0), fChildNodeList(this)
 {    
 }
 
 // This only makes a shallow copy, cloneChildren must also be called for a
 // deep clone
 DOMParentNode::DOMParentNode(const DOMParentNode &other)  :
-    fChildNodeList(castToNode(this))
+    fChildNodeList(this)
 {
     this->fOwnerDocument = other.fOwnerDocument;
 
-- 
GitLab