From baf0588e16abc4390d12f740ac1e4a2fa52d38b1 Mon Sep 17 00:00:00 2001 From: Khaled Noaman <knoaman@apache.org> Date: Tue, 30 Jul 2002 13:31:07 +0000 Subject: [PATCH] Clone entity ref nodes only once. git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174080 13f79535-47bb-0310-9956-ffa450edef68 --- src/xercesc/dom/impl/DOMEntityImpl.cpp | 11 +++++++++-- src/xercesc/dom/impl/DOMEntityImpl.hpp | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/xercesc/dom/impl/DOMEntityImpl.cpp b/src/xercesc/dom/impl/DOMEntityImpl.cpp index 870bb6871..4c6f8ea77 100644 --- a/src/xercesc/dom/impl/DOMEntityImpl.cpp +++ b/src/xercesc/dom/impl/DOMEntityImpl.cpp @@ -72,7 +72,8 @@ DOMEntityImpl::DOMEntityImpl(DOMDocument *ownerDoc, const XMLCh *eName) fSystemId(0), fActualEncoding(0), fEncoding(0), - fVersion(0) + fVersion(0), + fEntityRefNodeCloned(false) { fRefEntity = 0; fName = ((DOMDocumentImpl *)ownerDoc)->getPooledString(eName); @@ -85,7 +86,8 @@ DOMEntityImpl::DOMEntityImpl(const DOMEntityImpl &other, bool deep) fParent(other.fParent), fActualEncoding(other.fActualEncoding), fEncoding(other.fEncoding), - fVersion(other.fVersion) + fVersion(other.fVersion), + fEntityRefNodeCloned(false) { fName = other.fName; if (deep) @@ -178,10 +180,14 @@ DOMEntityReference* DOMEntityImpl::getEntityRef() const void DOMEntityImpl::cloneEntityRefTree() const { + if (fEntityRefNodeCloned) + return; + // cast off const. This method is const because it is // called from a bunch of logically const methods, like // getFirstChild(). DOMEntityImpl *ncThis = (DOMEntityImpl *)this; + //lazily clone the entityRef tree to this entity if (fParent.fFirstChild != 0) return; @@ -189,6 +195,7 @@ void DOMEntityImpl::cloneEntityRefTree() const if (!fRefEntity) return; + ncThis->fEntityRefNodeCloned = true; ncThis->fNode.setReadOnly(false, true); ncThis->fParent.cloneChildren(fRefEntity); ncThis->fNode.setReadOnly(true, true); diff --git a/src/xercesc/dom/impl/DOMEntityImpl.hpp b/src/xercesc/dom/impl/DOMEntityImpl.hpp index 99ee9ebaf..7f6797253 100644 --- a/src/xercesc/dom/impl/DOMEntityImpl.hpp +++ b/src/xercesc/dom/impl/DOMEntityImpl.hpp @@ -92,7 +92,7 @@ private: XMLCh* fActualEncoding; XMLCh* fEncoding; XMLCh* fVersion; - + bool fEntityRefNodeCloned; // private helper function void cloneEntityRefTree() const; -- GitLab