cargilld 2004/11/17 17:35:20
Modified: c/src/xercesc/dom/impl DOMDeepNodeListPool.c
c/src/xercesc/util NameIdPool.c RefHash2KeysTableOf.c
RefHash3KeysIdPool.c RefHashTableOf.c
ValueHashTableOf.c XMLString.cpp
Log:
Performance improvement to utility classes from Christian Will. Avoid
unnecessary checks and replace with assert calls.
Revision Changes Path
1.12 +6 -6 xml-xerces/c/src/xercesc/dom/impl/DOMDeepNodeListPool.c
Index: DOMDeepNodeListPool.c
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMDeepNodeListPool.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DOMDeepNodeListPool.c 8 Sep 2004 13:55:51 -0000 1.11
+++ DOMDeepNodeListPool.c 18 Nov 2004 01:35:20 -0000 1.12
@@ -27,6 +27,8 @@
#include <xercesc/dom/impl/DOMDeepNodeListPool.hpp>
#endif
+#include <assert.h>
+
XERCES_CPP_NAMESPACE_BEGIN
@@ -362,8 +364,7 @@
{
// Hash the key
hashVal = fHash->getHashVal(key1, fHashModulus, fMemoryManager);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
// Search that bucket for the key
DOMDeepNodeListPoolTableBucketElem<TVal>* curElem = fBucketList[hashVal];
@@ -398,9 +399,8 @@
{
// Hash the key
hashVal = fHash->getHashVal(key1, fHashModulus, fMemoryManager);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
-
+ assert(hashVal < fHashModulus);
+
// Search that bucket for the key
const DOMDeepNodeListPoolTableBucketElem<TVal>* curElem =
fBucketList[hashVal];
while (curElem)
1.10 +6 -5 xml-xerces/c/src/xercesc/util/NameIdPool.c
Index: NameIdPool.c
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/NameIdPool.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- NameIdPool.c 8 Sep 2004 13:56:22 -0000 1.9
+++ NameIdPool.c 18 Nov 2004 01:35:20 -0000 1.10
@@ -16,6 +16,9 @@
/**
* $Log$
+ * Revision 1.10 2004/11/18 01:35:20 cargilld
+ * Performance improvement to utility classes from Christian Will. Avoid
unnecessary checks and replace with assert calls.
+ *
* Revision 1.9 2004/09/08 13:56:22 peiyongz
* Apache License Version 2.0
*
@@ -70,6 +73,7 @@
#include <xercesc/util/IllegalArgumentException.hpp>
#include <xercesc/util/NoSuchElementException.hpp>
#include <xercesc/util/RuntimeException.hpp>
+#include <assert.h>
XERCES_CPP_NAMESPACE_BEGIN
@@ -300,8 +304,7 @@
// Hash the key
hashVal = XMLString::hash(key, fHashModulus, fMemoryManager);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::Pool_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
// Search that bucket for the key
NameIdPoolBucketElem<TElem>* curElem = fBucketList[hashVal];
@@ -320,9 +323,7 @@
{
// Hash the key
hashVal = XMLString::hash(key, fHashModulus, fMemoryManager);
-
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::Pool_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
// Search that bucket for the key
const NameIdPoolBucketElem<TElem>* curElem = fBucketList[hashVal];
1.12 +8 -9 xml-xerces/c/src/xercesc/util/RefHash2KeysTableOf.c
Index: RefHash2KeysTableOf.c
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/RefHash2KeysTableOf.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- RefHash2KeysTableOf.c 22 Sep 2004 11:14:22 -0000 1.11
+++ RefHash2KeysTableOf.c 18 Nov 2004 01:35:20 -0000 1.12
@@ -16,6 +16,9 @@
/**
* $Log$
+ * Revision 1.12 2004/11/18 01:35:20 cargilld
+ * Performance improvement to utility classes from Christian Will. Avoid
unnecessary checks and replace with assert calls.
+ *
* Revision 1.11 2004/09/22 11:14:22 amassari
* Reorder initialization of variables in constructor
*
@@ -76,6 +79,7 @@
#endif
#include <xercesc/util/NullPointerException.hpp>
+#include <assert.h>
XERCES_CPP_NAMESPACE_BEGIN
@@ -218,9 +222,7 @@
{
// Hash the key
unsigned int hashVal = fHash->getHashVal(key1, fHashModulus);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
-
+ assert(hashVal < fHashModulus);
//
// Search the given bucket for this key. Keep up with the previous
// element so we can patch around it.
@@ -337,8 +339,7 @@
{
// Hash the key
hashVal = fHash->getHashVal(key1, fHashModulus, fMemoryManager);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
// Search that bucket for the key
RefHash2KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal];
@@ -357,8 +358,7 @@
{
// Hash the key
hashVal = fHash->getHashVal(key1, fHashModulus, fMemoryManager);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
// Search that bucket for the key
const RefHash2KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal];
@@ -378,8 +378,7 @@
{
// Hash the key
hashVal = fHash->getHashVal(key1, fHashModulus);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
//
// Search the given bucket for this key. Keep up with the previous
1.14 +6 -4 xml-xerces/c/src/xercesc/util/RefHash3KeysIdPool.c
Index: RefHash3KeysIdPool.c
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/RefHash3KeysIdPool.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- RefHash3KeysIdPool.c 8 Sep 2004 13:56:22 -0000 1.13
+++ RefHash3KeysIdPool.c 18 Nov 2004 01:35:20 -0000 1.14
@@ -16,6 +16,9 @@
/**
* $Log$
+ * Revision 1.14 2004/11/18 01:35:20 cargilld
+ * Performance improvement to utility classes from Christian Will. Avoid
unnecessary checks and replace with assert calls.
+ *
* Revision 1.13 2004/09/08 13:56:22 peiyongz
* Apache License Version 2.0
*
@@ -79,6 +82,7 @@
#endif
#include <xercesc/util/NullPointerException.hpp>
+#include <assert.h>
XERCES_CPP_NAMESPACE_BEGIN
@@ -390,8 +394,7 @@
{
// Hash the key
hashVal = fHash->getHashVal(key1, fHashModulus, fMemoryManager);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
// Search that bucket for the key
RefHash3KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal];
@@ -410,8 +413,7 @@
{
// Hash the key
hashVal = fHash->getHashVal(key1, fHashModulus);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
// Search that bucket for the key
const RefHash3KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal];
1.17 +9 -10 xml-xerces/c/src/xercesc/util/RefHashTableOf.c
Index: RefHashTableOf.c
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/RefHashTableOf.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- RefHashTableOf.c 8 Sep 2004 13:56:23 -0000 1.16
+++ RefHashTableOf.c 18 Nov 2004 01:35:20 -0000 1.17
@@ -16,6 +16,9 @@
/**
* $Log$
+ * Revision 1.17 2004/11/18 01:35:20 cargilld
+ * Performance improvement to utility classes from Christian Will. Avoid
unnecessary checks and replace with assert calls.
+ *
* Revision 1.16 2004/09/08 13:56:23 peiyongz
* Apache License Version 2.0
*
@@ -113,6 +116,7 @@
#endif
#include <xercesc/util/NullPointerException.hpp>
+#include <assert.h>
XERCES_CPP_NAMESPACE_BEGIN
@@ -271,8 +275,7 @@
// Hash the key
TVal* retVal = 0;
unsigned int hashVal = fHash->getHashVal(key, fHashModulus,
fMemoryManager);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
//
// Search the given bucket for this key. Keep up with the previous
@@ -476,8 +479,7 @@
nextElem = curElem->fNext;
unsigned int hashVal = fHash->getHashVal(curElem->fKey,
fHashModulus, fMemoryManager);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
RefHashTableBucketElem<TVal>* newHeadElem = fBucketList[hashVal];
@@ -498,8 +500,7 @@
{
// Hash the key
hashVal = fHash->getHashVal(key, fHashModulus, fMemoryManager);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
// Search that bucket for the key
RefHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
@@ -518,8 +519,7 @@
{
// Hash the key
hashVal = fHash->getHashVal(key, fHashModulus, fMemoryManager);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
// Search that bucket for the key
const RefHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
@@ -539,8 +539,7 @@
{
// Hash the key
hashVal = fHash->getHashVal(key, fHashModulus, fMemoryManager);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
//
// Search the given bucket for this key. Keep up with the previous
1.10 +7 -6 xml-xerces/c/src/xercesc/util/ValueHashTableOf.c
Index: ValueHashTableOf.c
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/ValueHashTableOf.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ValueHashTableOf.c 8 Sep 2004 13:56:23 -0000 1.9
+++ ValueHashTableOf.c 18 Nov 2004 01:35:20 -0000 1.10
@@ -16,6 +16,9 @@
/**
* $Log$
+ * Revision 1.10 2004/11/18 01:35:20 cargilld
+ * Performance improvement to utility classes from Christian Will. Avoid
unnecessary checks and replace with assert calls.
+ *
* Revision 1.9 2004/09/08 13:56:23 peiyongz
* Apache License Version 2.0
*
@@ -48,6 +51,7 @@
#endif
#include <xercesc/util/NullPointerException.hpp>
+#include <assert.h>
XERCES_CPP_NAMESPACE_BEGIN
@@ -219,8 +223,7 @@
{
// Hash the key
hashVal = fHash->getHashVal(key, fHashModulus, fMemoryManager);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
// Search that bucket for the key
ValueHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
@@ -239,8 +242,7 @@
{
// Hash the key
hashVal = fHash->getHashVal(key, fHashModulus, fMemoryManager);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
// Search that bucket for the key
const ValueHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
@@ -260,8 +262,7 @@
{
// Hash the key
hashVal = fHash->getHashVal(key, fHashModulus);
- if (hashVal > fHashModulus)
- ThrowXMLwithMemMgr(RuntimeException,
XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
+ assert(hashVal < fHashModulus);
//
// Search the given bucket for this key. Keep up with the previous
1.38 +9 -11 xml-xerces/c/src/xercesc/util/XMLString.cpp
Index: XMLString.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLString.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- XMLString.cpp 28 Sep 2004 09:35:05 -0000 1.37
+++ XMLString.cpp 18 Nov 2004 01:35:20 -0000 1.38
@@ -26,6 +26,7 @@
#include <ctype.h>
#include <stdlib.h>
#include <errno.h>
+#include <assert.h>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
@@ -296,10 +297,9 @@
unsigned int XMLString::hash( const char* const tohash
, const unsigned int hashModulus
- , MemoryManager* const manager)
+ , MemoryManager* const)
{
- if (!hashModulus)
- ThrowXMLwithMemMgr(IllegalArgumentException,
XMLExcepts::Pool_ZeroModulus, manager);
+ assert(hashModulus);
unsigned int hashVal = 0;
if (tohash) {
@@ -1099,10 +1099,9 @@
unsigned int XMLString::hash( const XMLCh* const tohash
, const unsigned int hashModulus
- , MemoryManager* const manager)
-{
- if (!hashModulus)
- ThrowXMLwithMemMgr(IllegalArgumentException,
XMLExcepts::Pool_ZeroModulus, manager);
+ , MemoryManager* const)
+{
+ assert(hashModulus);
unsigned int hashVal = 0;
if (tohash) {
@@ -1195,10 +1194,9 @@
unsigned int XMLString::hashN( const XMLCh* const tohash
, const unsigned int n
, const unsigned int hashModulus
- , MemoryManager* const manager)
+ , MemoryManager* const)
{
- if (!hashModulus)
- ThrowXMLwithMemMgr(IllegalArgumentException,
XMLExcepts::Pool_ZeroModulus, manager);
+ assert(hashModulus);
unsigned int hashVal = 0;
if (tohash) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]