You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2008/03/07 17:02:29 UTC
svn commit: r634722 - in /xerces/c/trunk/src/xercesc:
dom/impl/DOMAttrImpl.cpp dom/impl/DOMAttrMapImpl.cpp
dom/impl/DOMDocumentImpl.cpp util/PlatformUtils.hpp
Author: amassari
Date: Fri Mar 7 08:02:27 2008
New Revision: 634722
URL: http://svn.apache.org/viewvc?rev=634722&view=rev
Log:
Performance improvements; cleanup of unused methods
Modified:
xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.cpp
xerces/c/trunk/src/xercesc/dom/impl/DOMAttrMapImpl.cpp
xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp
xerces/c/trunk/src/xercesc/util/PlatformUtils.hpp
Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.cpp?rev=634722&r1=634721&r2=634722&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMAttrImpl.cpp Fri Mar 7 08:02:27 2008
@@ -186,7 +186,7 @@
}
if (val != 0) // Create and add the new one
- appendChild(doc->createTextNode(val));
+ fParent.appendChildFast(doc->createTextNode(val));
fNode.isSpecified(true);
fParent.changed();
Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMAttrMapImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMAttrMapImpl.cpp?rev=634722&r1=634721&r2=634722&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMAttrMapImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMAttrMapImpl.cpp Fri Mar 7 08:02:27 2008
@@ -68,7 +68,7 @@
{
unsigned int size = srcmap->fNodes->size();
if(size > 0) {
- DOMDocument *doc = fOwnerNode->getOwnerDocument();
+ DOMDocumentImpl *doc = (DOMDocumentImpl*)fOwnerNode->getOwnerDocument();
fNodes = new (doc) DOMNodeVector(doc, size);
}
}
@@ -185,7 +185,7 @@
i=-1-i; // Insert point (may be end of list)
if(0==fNodes)
{
- fNodes=new (doc) DOMNodeVector(doc);
+ fNodes=new ((DOMDocumentImpl*)doc) DOMNodeVector(doc);
}
fNodes->insertElementAt(arg,i);
}
@@ -261,7 +261,7 @@
if (i<0)
i = -1 - i;
if(0==fNodes)
- fNodes=new (doc) DOMNodeVector(doc);
+ fNodes=new ((DOMDocumentImpl*)doc) DOMNodeVector(doc);
fNodes->insertElementAt(arg,i);
}
if (previous != 0) {
Modified: xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp?rev=634722&r1=634721&r2=634722&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/dom/impl/DOMDocumentImpl.cpp Fri Mar 7 08:02:27 2008
@@ -541,7 +541,8 @@
bool DOMDocumentImpl::isXMLName(const XMLCh *s)
{
- if (XMLString::equals(fXmlVersion, XMLUni::fgVersion1_1))
+ // fXmlVersion points directly to the static constants
+ if (fXmlVersion==XMLUni::fgVersion1_1)
return XMLChar1_1::isValidName(s);
else
return XMLChar1_0::isValidName(s);
@@ -966,12 +967,18 @@
}
void DOMDocumentImpl::setXmlVersion(const XMLCh* version){
- if ((version && *version) &&
- !XMLString::equals(version, XMLUni::fgVersion1_0) &&
- !XMLString::equals(version, XMLUni::fgVersion1_1))
- throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, getMemoryManager());
- fXmlVersion = cloneString(version);
+ // store the static strings, so that comparisons will be faster
+ if(version==0)
+ fXmlVersion = 0;
+ else if(*version==0)
+ fXmlVersion = XMLUni::fgZeroLenString;
+ else if(XMLString::equals(version, XMLUni::fgVersion1_0))
+ fXmlVersion = XMLUni::fgVersion1_0;
+ else if(XMLString::equals(version, XMLUni::fgVersion1_1))
+ fXmlVersion = XMLUni::fgVersion1_1;
+ else
+ throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, getMemoryManager());
}
const XMLCh* DOMDocumentImpl::getDocumentURI() const
Modified: xerces/c/trunk/src/xercesc/util/PlatformUtils.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/PlatformUtils.hpp?rev=634722&r1=634721&r2=634722&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/PlatformUtils.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/PlatformUtils.hpp Fri Mar 7 08:02:27 2008
@@ -121,23 +121,13 @@
*/
static MemoryManager* fgMemoryManager;
- /** The array-allocating memory manager
- *
- * This memory manager always allocates memory by calling the
- * global new[] operator. It may be used to allocate memory
- * where such memory needs to be deletable by calling delete [].
- * Since this allocator is always guaranteed to do the same thing
- * there is no reason, nor facility, to override it.
- */
- static MemoryManager* fgArrayMemoryManager;
-
- static XMLFileMgr* fgFileMgr;
- static XMLMutexMgr* fgMutexMgr;
- static XMLAtomicOpMgr* fgAtomicOpMgr;
+ static XMLFileMgr* fgFileMgr;
+ static XMLMutexMgr* fgMutexMgr;
+ static XMLAtomicOpMgr* fgAtomicOpMgr;
- static XMLMutex* fgAtomicMutex;
+ static XMLMutex* fgAtomicMutex;
- static bool fgXMLChBigEndian;
+ static bool fgXMLChBigEndian;
//@}
@@ -219,9 +209,8 @@
*
* @param manager The MemoryManager to use to allocate objects
*/
- static XMLFileMgr*
- makeFileMgr(MemoryManager* const manager);
-
+ static XMLFileMgr* makeFileMgr(MemoryManager* const manager);
+
/** Get the current file position
*
* This must be implemented by the per-platform driver, which should
@@ -347,7 +336,7 @@
static XMLSize_t readFileBuffer
(
FileHandle theFile
- , const XMLSize_t toRead
+ , const XMLSize_t toRead
, XMLByte* const toFill
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
@@ -541,7 +530,7 @@
*
* @param manager The MemoryManager to use to allocate objects
*/
- static XMLMutexMgr* makeMutexMgr(MemoryManager* const manager);
+ static XMLMutexMgr* makeMutexMgr(MemoryManager* const manager);
/** Closes a mutex handle
*
@@ -614,7 +603,7 @@
*
* @param manager The MemoryManager to use to allocate objects
*/
- static XMLAtomicOpMgr* makeAtomicOpMgr(MemoryManager* const manager);
+ static XMLAtomicOpMgr* makeAtomicOpMgr(MemoryManager* const manager);
/** Conditionally updates or returns a single word variable atomically
@@ -701,7 +690,7 @@
/** @name NEL Character Handling */
//@{
- /**
+ /**
* This function enables the recognition of NEL(0x85) char and LSEP (0x2028) as newline chars
* which is disabled by default.
* It is only called once per process. Once it is set, any subsequent calls
@@ -723,7 +712,7 @@
/** @name Strict IANA Encoding Checking */
//@{
- /**
+ /**
* This function enables/disables strict IANA encoding names checking.
*
* The strict checking is disabled by default.
@@ -740,15 +729,15 @@
*/
static bool isStrictIANAEncoding();
//@}
-
+
/**
* Aligns the specified pointer per platform block allocation
- * requirements.
- *
- * The results of this function may be altered by defining
- * XML_PLATFORM_NEW_BLOCK_ALIGNMENT.
- */
- static inline size_t alignPointerForNewBlockAllocation(size_t ptrSize);
+ * requirements.
+ *
+ * The results of this function may be altered by defining
+ * XML_PLATFORM_NEW_BLOCK_ALIGNMENT.
+ */
+ static inline size_t alignPointerForNewBlockAllocation(size_t ptrSize);
private :
// -----------------------------------------------------------------------
@@ -789,22 +778,6 @@
*/
static XMLTransService* makeTransService();
- /** Does initialization for a particular platform
- *
- * Each per-platform driver must implement this to do any low level
- * system initialization required. It <b>cannot</b> use any XML
- * parser or utilities services!
- */
- static void platformInit();
-
- /** Does termination for a particular platform
- *
- * Each per-platform driver must implement this to do any low level
- * system resource cleanup required. It <b>cannot</b> use any XML
- * parser or utilities services!
- */
- static void platformTerm();
-
/** Search for sequence, slash dot dot slash
*
* @param srcPath the path to search
@@ -838,8 +811,8 @@
// XMLPlatformUtils: alignPointerForNewBlockAllocation
// ---------------------------------------------------------------------------
// Calculate alignment required by platform for a new
-// block allocation. We use this in our custom allocators
-// to ensure that returned blocks are properly aligned.
+// block allocation. We use this in our custom allocators
+// to ensure that returned blocks are properly aligned.
// Note that, although this will take a pointer and return the position
// at which it should be placed for correct alignment, in our code
// we normally use size_t parameters to discover what the alignment
@@ -859,23 +832,23 @@
inline size_t
XMLPlatformUtils::alignPointerForNewBlockAllocation(size_t ptrSize)
{
- // Macro XML_PLATFORM_NEW_BLOCK_ALIGNMENT may be defined
- // as needed to dictate alignment requirements on a
- // per-architecture basis. In the absense of that we
- // take an educated guess.
- #ifdef XML_PLATFORM_NEW_BLOCK_ALIGNMENT
- size_t alignment = XML_PLATFORM_NEW_BLOCK_ALIGNMENT;
- #else
- size_t alignment = (sizeof(void*) >= sizeof(double)) ? sizeof(void*) : sizeof(double);
- #endif
-
- // Calculate current alignment of pointer
- size_t current = ptrSize % alignment;
-
- // Adjust pointer alignment as needed
- return (current == 0)
- ? ptrSize
- : (ptrSize + alignment - current);
+ // Macro XML_PLATFORM_NEW_BLOCK_ALIGNMENT may be defined
+ // as needed to dictate alignment requirements on a
+ // per-architecture basis. In the absense of that we
+ // take an educated guess.
+#ifdef XML_PLATFORM_NEW_BLOCK_ALIGNMENT
+ static const size_t alignment = XML_PLATFORM_NEW_BLOCK_ALIGNMENT;
+#else
+ static const size_t alignment = (sizeof(void*) >= sizeof(double)) ? sizeof(void*) : sizeof(double);
+#endif
+
+ // Calculate current alignment of pointer
+ size_t current = ptrSize % alignment;
+
+ // Adjust pointer alignment as needed
+ return (current == 0)
+ ? ptrSize
+ : (ptrSize + alignment - current);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org