Author: amassari
Date: Mon Apr 21 10:56:39 2008
New Revision: 650214

URL: http://svn.apache.org/viewvc?rev=650214&view=rev
Log:
Performance improvements

Modified:
    xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp
    xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp
    xerces/c/trunk/src/xercesc/util/HashXMLCh.cpp
    xerces/c/trunk/src/xercesc/util/RefHash2KeysTableOf.c
    xerces/c/trunk/src/xercesc/util/RefHash3KeysIdPool.c
    xerces/c/trunk/src/xercesc/util/RefHashTableOf.c
    xerces/c/trunk/src/xercesc/util/ValueHashTableOf.c
    xerces/c/trunk/src/xercesc/util/XMLString.hpp

Modified: xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp?rev=650214&r1=650213&r2=650214&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp Mon Apr 21 10:56:39 
2008
@@ -2253,7 +2253,7 @@
     );
     fUndeclaredAttrRegistry = new (fMemoryManager) RefHashTableOf<unsigned int>
     (
-        7, false, 0, fMemoryManager
+        7, false, fMemoryManager
     );
 
     if (fValidator)

Modified: xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp?rev=650214&r1=650213&r2=650214&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp Mon Apr 21 10:56:39 2008
@@ -1864,10 +1864,11 @@
     //  is going to be. We turn on end of entity exceptions when we do this
     //  in order to catch the scenario where the current entity ended at
     //  the > of some markup.
-    XMLCh nextCh;
+    XMLCh nextCh=0;
 
+    XMLReader* curReader=fReaderMgr.getCurrentReader();
     // avoid setting up the ThrowEOEJanitor if we know that we have data in 
the current reader
-    if(fReaderMgr.getCurrentReader() && 
fReaderMgr.getCurrentReader()->charsLeftInBuffer()>0)
+    if(curReader && curReader->charsLeftInBuffer()>0)
         nextCh = fReaderMgr.peekNextChar();
     else
     {

Modified: xerces/c/trunk/src/xercesc/util/HashXMLCh.cpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/HashXMLCh.cpp?rev=650214&r1=650213&r2=650214&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/HashXMLCh.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/HashXMLCh.cpp Mon Apr 21 10:56:39 2008
@@ -36,7 +36,7 @@
 
 bool HashXMLCh::equals(const void *const key1, const void *const key2)
 {
-       return (XMLString::equals((XMLCh*)key1, (XMLCh*)key2)) ? true : false;
+       return XMLString::equals((const XMLCh*)key1, (const XMLCh*)key2);
 }
 
 XERCES_CPP_NAMESPACE_END

Modified: xerces/c/trunk/src/xercesc/util/RefHash2KeysTableOf.c
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/RefHash2KeysTableOf.c?rev=650214&r1=650213&r2=650214&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/RefHash2KeysTableOf.c (original)
+++ xerces/c/trunk/src/xercesc/util/RefHash2KeysTableOf.c Mon Apr 21 10:56:39 
2008
@@ -42,16 +42,13 @@
                                               , const bool           adoptElems
                                               , MemoryManager* const manager)
     : fMemoryManager(manager)
-       , fAdoptedElems(adoptElems)
+    , fAdoptedElems(adoptElems)
     , fBucketList(0)
     , fHashModulus(modulus)
     , fCount(0)
     , fHash(0)
 {
     initialize(modulus);
-       
-       // create default hasher
-       fHash = new (fMemoryManager) HashXMLCh();
 }
 
 template <class TVal>
@@ -59,38 +56,35 @@
                                               , const bool           adoptElems
                                               , HashBase*            hashBase
                                               , MemoryManager* const manager)
-       : fMemoryManager(manager)
+    : fMemoryManager(manager)
     , fAdoptedElems(adoptElems)
     , fBucketList(0)
     , fHashModulus(modulus)
     , fCount(0)
     , fHash(0)
 {
-       initialize(modulus);
-       // set hasher
-       fHash = hashBase;
+    initialize(modulus);
+    // set hasher
+    fHash = hashBase;
 }
 
 template <class TVal>
 RefHash2KeysTableOf<TVal>::RefHash2KeysTableOf(const unsigned int modulus,
                                                MemoryManager* const manager)
-       : fMemoryManager(manager)
+    : fMemoryManager(manager)
     , fAdoptedElems(true)
     , fBucketList(0)
     , fHashModulus(modulus)
     , fCount(0)
     , fHash(0)
 {
-       initialize(modulus);
-
-       // create default hasher
-       fHash = new (fMemoryManager) HashXMLCh();
+    initialize(modulus);
 }
 
 template <class TVal>
 void RefHash2KeysTableOf<TVal>::initialize(const unsigned int modulus)
 {
-       if (modulus == 0)
+    if (modulus == 0)
         ThrowXMLwithMemMgr(IllegalArgumentException, 
XMLExcepts::HshTbl_ZeroModulus, fMemoryManager);
 
     // Allocate the bucket list and zero them
@@ -107,7 +101,9 @@
 
     // Then delete the bucket list & hasher
     fMemoryManager->deallocate(fBucketList); //delete [] fBucketList;
-       delete fHash;
+    fBucketList = 0;
+    delete fHash;
+    fHash = 0;
 }
 
 
@@ -131,7 +127,7 @@
 removeKey(const void* const key1, const int key2)
 {
     // Hash the key
-    unsigned int hashVal = fHash->getHashVal(key1, fHashModulus);
+    unsigned int hashVal = fHash==0?XMLString::hash((const XMLCh*)key1, 
fHashModulus, fMemoryManager) : fHash->getHashVal(key1, fHashModulus, 
fMemoryManager);
     assert(hashVal < fHashModulus);
 
     //
@@ -143,7 +139,7 @@
 
     while (curElem)
     {
-        if (fHash->equals(key1, curElem->fKey1) && (key2==curElem->fKey2))
+        if((key2==curElem->fKey2) && (fHash==0?XMLString::equals((const 
XMLCh*)key1, (const XMLCh*)curElem->fKey1) : fHash->equals(key1, 
curElem->fKey1)))
         {
             if (!lastElem)
             {
@@ -182,7 +178,7 @@
 removeKey(const void* const key1)
 {
     // Hash the key
-    unsigned int hashVal = fHash->getHashVal(key1, fHashModulus);
+    unsigned int hashVal = fHash==0?XMLString::hash((const XMLCh*)key1, 
fHashModulus, fMemoryManager) : fHash->getHashVal(key1, fHashModulus, 
fMemoryManager);
     assert(hashVal < fHashModulus);
 
     //
@@ -194,7 +190,7 @@
 
     while (curElem)
     {
-        if (fHash->equals(key1, curElem->fKey1))
+        if(fHash==0?XMLString::equals((const XMLCh*)key1, (const 
XMLCh*)curElem->fKey1) : fHash->equals(key1, curElem->fKey1))
         {
             if (!lastElem)
             {
@@ -270,7 +266,7 @@
 template <class TVal> void RefHash2KeysTableOf<TVal>::transferElement(const 
void* const key1, void* key2)
 {
     // Hash the key
-    unsigned int hashVal = fHash->getHashVal(key1, fHashModulus);
+    unsigned int hashVal = fHash==0?XMLString::hash((const XMLCh*)key1, 
fHashModulus, fMemoryManager) : fHash->getHashVal(key1, fHashModulus, 
fMemoryManager);
     assert(hashVal < fHashModulus);
 
     //
@@ -283,7 +279,7 @@
     while (curElem)
     {
         // if this element has the same primary key, remove it and add it 
using the new primary key
-        if (fHash->equals(key1, curElem->fKey1))
+        if(fHash==0?XMLString::equals((const XMLCh*)key1, (const 
XMLCh*)curElem->fKey1) : fHash->equals(key1, curElem->fKey1))
         {
             if (!lastElem)
             {
@@ -304,8 +300,8 @@
                 if (fAdoptedElems)
                     delete newBucket->fData;
                 newBucket->fData = curElem->fData;
-                       newBucket->fKey1 = key2;
-                       newBucket->fKey2 = curElem->fKey2;
+                newBucket->fKey1 = key2;
+                newBucket->fKey2 = curElem->fKey2;
             }
              else
             {
@@ -396,8 +392,8 @@
         if (fAdoptedElems)
             delete newBucket->fData;
         newBucket->fData = valueToAdopt;
-               newBucket->fKey1 = key1;
-               newBucket->fKey2 = key2;
+        newBucket->fKey1 = key1;
+        newBucket->fKey2 = key2;
     }
      else
     {
@@ -418,14 +414,14 @@
 findBucketElem(const void* const key1, const int key2, unsigned int& hashVal)
 {
     // Hash the key
-    hashVal = fHash->getHashVal(key1, fHashModulus, fMemoryManager);
+    hashVal = fHash==0?XMLString::hash((const XMLCh*)key1, fHashModulus, 
fMemoryManager) : fHash->getHashVal(key1, fHashModulus, fMemoryManager);
     assert(hashVal < fHashModulus);
 
     // Search that bucket for the key
     RefHash2KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal];
     while (curElem)
     {
-               if (key2==curElem->fKey2 && fHash->equals(key1, curElem->fKey1))
+        if((key2==curElem->fKey2) && (fHash==0?XMLString::equals((const 
XMLCh*)key1, (const XMLCh*)curElem->fKey1) : fHash->equals(key1, 
curElem->fKey1)))
             return curElem;
 
         curElem = curElem->fNext;
@@ -437,14 +433,14 @@
 findBucketElem(const void* const key1, const int key2, unsigned int& hashVal) 
const
 {
     // Hash the key
-    hashVal = fHash->getHashVal(key1, fHashModulus, fMemoryManager);
+    hashVal = fHash==0?XMLString::hash((const XMLCh*)key1, fHashModulus, 
fMemoryManager) : fHash->getHashVal(key1, fHashModulus, fMemoryManager);
     assert(hashVal < fHashModulus);
 
     // Search that bucket for the key
     const RefHash2KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal];
     while (curElem)
     {
-        if (fHash->equals(key1, curElem->fKey1) && (key2==curElem->fKey2))
+        if((key2==curElem->fKey2) && (fHash==0?XMLString::equals((const 
XMLCh*)key1, (const XMLCh*)curElem->fKey1) : fHash->equals(key1, 
curElem->fKey1)))
             return curElem;
 
         curElem = curElem->fNext;
@@ -480,7 +476,7 @@
             // Save the next element before we detach this one
             RefHash2KeysTableBucketElem<TVal>* nextElem = curElem->fNext;
 
-            const unsigned int hashVal = fHash->getHashVal(curElem->fKey1, 
newMod, fMemoryManager);
+            const unsigned int hashVal = fHash==0?XMLString::hash((const 
XMLCh*)curElem->fKey1, newMod, fMemoryManager) : 
fHash->getHashVal(curElem->fKey1, newMod, fMemoryManager);
             assert(hashVal < newMod);
             
             RefHash2KeysTableBucketElem<TVal>* newHeadElem = 
newBucketList[hashVal];
@@ -514,7 +510,7 @@
 RefHash2KeysTableOfEnumerator(RefHash2KeysTableOf<TVal>* const toEnum
                               , const bool adopt
                               , MemoryManager* const manager)
-       : fAdopted(adopt), fCurElem(0), fCurHash((unsigned int)-1), 
fToEnum(toEnum)
+    : fAdopted(adopt), fCurElem(0), fCurHash((unsigned int)-1), fToEnum(toEnum)
     , fMemoryManager(manager)
     , fLockPrimaryKey(0)
 {
@@ -590,7 +586,7 @@
 template <class TVal> void RefHash2KeysTableOfEnumerator<TVal>::Reset()
 {
     if(fLockPrimaryKey)
-        fCurHash=fToEnum->fHash->getHashVal(fLockPrimaryKey, 
fToEnum->fHashModulus, fMemoryManager);
+        fCurHash=fToEnum->fHash==0?XMLString::hash((const 
XMLCh*)fLockPrimaryKey, fToEnum->fHashModulus, fMemoryManager) : 
fToEnum->fHash->getHashVal(fLockPrimaryKey, fToEnum->fHashModulus, 
fMemoryManager);
     else
         fCurHash = (unsigned int)-1;
     fCurElem = 0;
@@ -616,7 +612,8 @@
             fCurElem = fToEnum->fBucketList[fCurHash];
         else
             fCurElem = fCurElem->fNext;
-        while (fCurElem && !fToEnum->fHash->equals(fLockPrimaryKey, 
fCurElem->fKey1) )
+        while (fCurElem && 
+               (fToEnum->fHash==0?!XMLString::equals((const 
XMLCh*)fLockPrimaryKey, (const XMLCh*)fCurElem->fKey1) : 
!fToEnum->fHash->equals(fLockPrimaryKey, fCurElem->fKey1)))
             fCurElem = fCurElem->fNext;
         // if we didn't found it, make so hasMoreElements() returns false
         if(!fCurElem)

Modified: xerces/c/trunk/src/xercesc/util/RefHash3KeysIdPool.c
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/RefHash3KeysIdPool.c?rev=650214&r1=650213&r2=650214&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/RefHash3KeysIdPool.c (original)
+++ xerces/c/trunk/src/xercesc/util/RefHash3KeysIdPool.c Mon Apr 21 10:56:39 
2008
@@ -52,13 +52,6 @@
 {
     initialize(modulus);
 
-    // create default hasher
-#if defined (XML_GCC_VERSION) && (XML_GCC_VERSION < 29600)
-                fHash = new HashXMLCh();
-#else
-    fHash = new (fMemoryManager) HashXMLCh();
-#endif
-
     //
     //  Allocate the initial id pointers array. We don't have to zero them
     //  out since the fIdCounter value tells us which ones are valid. The
@@ -76,7 +69,7 @@
                                             , HashBase*          hashBase
                                             , const unsigned int initSize
                                             , MemoryManager* const manager) :
-       fMemoryManager(manager)
+    fMemoryManager(manager)
     , fAdoptedElems(adoptElems)
     , fBucketList(0)
     , fHashModulus(modulus)
@@ -104,7 +97,7 @@
 RefHash3KeysIdPool<TVal>::RefHash3KeysIdPool( const unsigned int modulus
                                             , const unsigned int initSize
                                             , MemoryManager* const manager) :
-       fMemoryManager(manager)
+    fMemoryManager(manager)
     , fAdoptedElems(true)
     , fBucketList(0)
     , fHashModulus(modulus)
@@ -115,13 +108,6 @@
 {
     initialize(modulus);
 
-    // create default hasher
-#if defined (XML_GCC_VERSION) && (XML_GCC_VERSION < 29600)
-                fHash = new HashXMLCh();
-#else
-    fHash = new (fMemoryManager) HashXMLCh();
-#endif    
-
     //
     //  Allocate the initial id pointers array. We don't have to zero them
     //  out since the fIdCounter value tells us which ones are valid. The
@@ -135,7 +121,7 @@
 
 template <class TVal> void RefHash3KeysIdPool<TVal>::initialize(const unsigned 
int modulus)
 {
-       if (modulus == 0)
+    if (modulus == 0)
         ThrowXMLwithMemMgr(IllegalArgumentException, 
XMLExcepts::HshTbl_ZeroModulus, fMemoryManager);
 
     // Allocate the bucket list and zero them
@@ -152,8 +138,11 @@
 
     // Then delete the bucket list & hasher & id pointers list
     fMemoryManager->deallocate(fIdPtrs); //delete [] fIdPtrs;
+    fIdPtrs = 0;
     fMemoryManager->deallocate(fBucketList); //delete [] fBucketList;
+    fBucketList = 0;
     delete fHash;
+    fHash = 0;
 }
 
 
@@ -290,7 +279,7 @@
     //
     if (newBucket)
     {
-       retId = newBucket->fData->getId();
+        retId = newBucket->fData->getId();
         if (fAdoptedElems)
             delete newBucket->fData;
         newBucket->fData = valueToAdopt;
@@ -312,28 +301,28 @@
 #endif
         fBucketList[hashVal] = newBucket;    
 
-       //
-       //  Give this new one the next available id and add to the pointer list.
-       //  Expand the list if that is now required.
-       //
-       if (fIdCounter + 1 == fIdPtrsCount)
-       {
-               // Create a new count 1.5 times larger and allocate a new array
-               unsigned int newCount = (unsigned int)(fIdPtrsCount * 1.5);
-               TVal** newArray = (TVal**) fMemoryManager->allocate
-               (
-               newCount * sizeof(TVal*)
-               ); //new TVal*[newCount];
-
-               // Copy over the old contents to the new array
-               memcpy(newArray, fIdPtrs, fIdPtrsCount * sizeof(TVal*));
-
-               // Ok, toss the old array and store the new data
-               fMemoryManager->deallocate(fIdPtrs); //delete [] fIdPtrs;
-               fIdPtrs = newArray;
-               fIdPtrsCount = newCount;
-       }
-       retId = ++fIdCounter;
+        //
+        //  Give this new one the next available id and add to the pointer 
list.
+        //  Expand the list if that is now required.
+        //
+        if (fIdCounter + 1 == fIdPtrsCount)
+        {
+            // Create a new count 1.5 times larger and allocate a new array
+            unsigned int newCount = (unsigned int)(fIdPtrsCount * 1.5);
+            TVal** newArray = (TVal**) fMemoryManager->allocate
+            (
+                newCount * sizeof(TVal*)
+            ); //new TVal*[newCount];
+
+            // Copy over the old contents to the new array
+            memcpy(newArray, fIdPtrs, fIdPtrsCount * sizeof(TVal*));
+
+            // Ok, toss the old array and store the new data
+            fMemoryManager->deallocate(fIdPtrs); //delete [] fIdPtrs;
+            fIdPtrs = newArray;
+            fIdPtrsCount = newCount;
+        }
+        retId = ++fIdCounter;
     }
     
     fIdPtrs[retId] = valueToAdopt;
@@ -352,14 +341,14 @@
 findBucketElem(const void* const key1, const int key2, const int key3, 
unsigned int& hashVal)
 {
     // Hash the key
-    hashVal = fHash->getHashVal(key1, fHashModulus, fMemoryManager);
+    hashVal = fHash==0?XMLString::hash((const XMLCh*)key1, fHashModulus, 
fMemoryManager) : fHash->getHashVal(key1, fHashModulus, fMemoryManager);
     assert(hashVal < fHashModulus);
 
     // Search that bucket for the key
     RefHash3KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal];
     while (curElem)
     {
-               if (key2==curElem->fKey2 && key3==curElem->fKey3 && 
fHash->equals(key1, curElem->fKey1))
+        if((key2==curElem->fKey2) && (key3==curElem->fKey3) && 
(fHash==0?XMLString::equals((const XMLCh*)key1, (const XMLCh*)curElem->fKey1) : 
fHash->equals(key1, curElem->fKey1)))
             return curElem;
 
         curElem = curElem->fNext;
@@ -371,14 +360,14 @@
 findBucketElem(const void* const key1, const int key2, const int key3, 
unsigned int& hashVal) const
 {
     // Hash the key
-    hashVal = fHash->getHashVal(key1, fHashModulus);
+    hashVal = fHash==0?XMLString::hash((const XMLCh*)key1, fHashModulus, 
fMemoryManager) : fHash->getHashVal(key1, fHashModulus, fMemoryManager);
     assert(hashVal < fHashModulus);
 
     // Search that bucket for the key
     const RefHash3KeysTableBucketElem<TVal>* curElem = fBucketList[hashVal];
     while (curElem)
     {
-        if (fHash->equals(key1, curElem->fKey1) && (key2==curElem->fKey2) && 
(key3==curElem->fKey3))
+        if((key2==curElem->fKey2) && (key3==curElem->fKey3) && 
(fHash==0?XMLString::equals((const XMLCh*)key1, (const XMLCh*)curElem->fKey1) : 
fHash->equals(key1, curElem->fKey1)))
             return curElem;
 
         curElem = curElem->fNext;
@@ -394,7 +383,7 @@
 RefHash3KeysIdPoolEnumerator(RefHash3KeysIdPool<TVal>* const toEnum
                              , const bool adopt
                              , MemoryManager* const manager)
-       : fAdoptedElems(adopt), fCurIndex(0), fToEnum(toEnum), 
fMemoryManager(manager)
+    : fAdoptedElems(adopt), fCurIndex(0), fToEnum(toEnum), 
fMemoryManager(manager)
 {
     if (!toEnum)
         ThrowXMLwithMemMgr(NullPointerException, 
XMLExcepts::CPtr_PointerIsZero, fMemoryManager);

Modified: xerces/c/trunk/src/xercesc/util/RefHashTableOf.c
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/RefHashTableOf.c?rev=650214&r1=650213&r2=650214&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/RefHashTableOf.c (original)
+++ xerces/c/trunk/src/xercesc/util/RefHashTableOf.c Mon Apr 21 10:56:39 2008
@@ -28,6 +28,7 @@
 #endif
 
 #include <xercesc/util/Janitor.hpp>
+#include <xercesc/util/XMLString.hpp>
 #include <xercesc/util/NullPointerException.hpp>
 #include <assert.h>
 #include <new>
@@ -52,9 +53,6 @@
 
 {
     initialize(modulus);
-       
-       // create default hasher
-       fHash = new (fMemoryManager) HashXMLCh();
 }
 
 template <class TVal>
@@ -89,9 +87,6 @@
     , fHash(0)
 {
     initialize(modulus);
-
-    // create default hasher
-    fHash = new (fMemoryManager) HashXMLCh();
 }
 
 template <class TVal> void RefHashTableOf<TVal>::initialize(const unsigned int 
modulus)
@@ -134,7 +129,7 @@
 removeKey(const void* const key)
 {
     // Hash the key
-    unsigned int hashVal = fHash->getHashVal(key, fHashModulus, 
fMemoryManager);
+    unsigned int hashVal = fHash==0?XMLString::hash((const XMLCh*)key, 
fHashModulus, fMemoryManager) : fHash->getHashVal(key, fHashModulus, 
fMemoryManager);
     assert(hashVal < fHashModulus);
 
     //
@@ -146,7 +141,7 @@
 
     while (curElem)
     {
-        if (fHash->equals(key, curElem->fKey))
+        if (fHash==0?XMLString::equals((const XMLCh*)key, (const 
XMLCh*)curElem->fKey) : fHash->equals(key, curElem->fKey))
         {
             if (!lastElem)
             {
@@ -167,9 +162,9 @@
                 delete curElem->fData;
 
             // Then delete the current element and move forward
-               // delete curElem;
+             // delete curElem;
             // destructor doesn't do anything...
-                       // curElem->~RefHashTableBucketElem();
+            // curElem->~RefHashTableBucketElem();
             fMemoryManager->deallocate(curElem);            
 
             fCount--;
@@ -210,9 +205,9 @@
                 delete curElem->fData;
 
             // Then delete the current element and move forward
-               // delete curElem;
+             // delete curElem;
             // destructor doesn't do anything...
-                       // curElem->~RefHashTableBucketElem();
+            // curElem->~RefHashTableBucketElem();
             fMemoryManager->deallocate(curElem);            
             curElem = nextElem;
         }
@@ -233,7 +228,7 @@
 {
     // Hash the key
     TVal* retVal = 0;
-    unsigned int hashVal = fHash->getHashVal(key, fHashModulus, 
fMemoryManager);
+    unsigned int hashVal = fHash==0?XMLString::hash((const XMLCh*)key, 
fHashModulus, fMemoryManager) : fHash->getHashVal(key, fHashModulus, 
fMemoryManager);
     assert(hashVal < fHashModulus);
 
     //
@@ -245,7 +240,7 @@
 
     while (curElem)
     {
-        if (fHash->equals(key, curElem->fKey))
+        if (fHash==0?XMLString::equals((const XMLCh*)key, (const 
XMLCh*)curElem->fKey) : fHash->equals(key, curElem->fKey))
         {
             if (!lastElem)
             {
@@ -263,7 +258,7 @@
             // Delete the current element
             // delete curElem;
             // destructor doesn't do anything...
-                       // curElem->~RefHashTableBucketElem();
+            // curElem->~RefHashTableBucketElem();
             fMemoryManager->deallocate(curElem);            
             break;
         }
@@ -293,6 +288,7 @@
     fMemoryManager->deallocate(fBucketList); //delete [] fBucketList;
     fBucketList = 0;
     delete fHash;
+    fHash = 0;
 }
 
 //
@@ -310,8 +306,6 @@
 
     if (hashBase)
         fHash = hashBase;
-    else
-        fHash = new (fMemoryManager) HashXMLCh();   // create default hasher
 }
 
 
@@ -404,12 +398,12 @@
         if (fAdoptedElems)
             delete newBucket->fData;
         newBucket->fData = valueToAdopt;
-               newBucket->fKey = key;
+        newBucket->fKey = key;
     }
     else
     {
         //newBucket = new (fMemoryManager) RefHashTableBucketElem<TVal>(key, 
valueToAdopt, fBucketList[hashVal]);
-               newBucket =
+        newBucket =
              new 
(fMemoryManager->allocate(sizeof(RefHashTableBucketElem<TVal>)))
              RefHashTableBucketElem<TVal>(key, valueToAdopt, 
fBucketList[hashVal]);        
         fBucketList[hashVal] = newBucket;
@@ -424,7 +418,7 @@
 // ---------------------------------------------------------------------------
 template <class TVal> void RefHashTableOf<TVal>::rehash()
 {
-    const unsigned int newMod = fHashModulus * 2;
+    const unsigned int newMod = (fHashModulus * 2) + 1;
 
     RefHashTableBucketElem<TVal>** newBucketList =
         (RefHashTableBucketElem<TVal>**) fMemoryManager->allocate
@@ -450,7 +444,7 @@
             // Save the next element before we detach this one
             RefHashTableBucketElem<TVal>* const nextElem = curElem->fNext;
 
-            const unsigned int hashVal = fHash->getHashVal(curElem->fKey, 
newMod, fMemoryManager);
+            const unsigned int hashVal = fHash==0?XMLString::hash((const 
XMLCh*)curElem->fKey, newMod, fMemoryManager) : 
fHash->getHashVal(curElem->fKey, newMod, fMemoryManager);
             assert(hashVal < newMod);
 
             RefHashTableBucketElem<TVal>* const newHeadElem = 
newBucketList[hashVal];
@@ -479,14 +473,14 @@
 findBucketElem(const void* const key, unsigned int& hashVal)
 {
     // Hash the key
-    hashVal = fHash->getHashVal(key, fHashModulus, fMemoryManager);
+    hashVal = fHash==0?XMLString::hash((const XMLCh*)key, fHashModulus, 
fMemoryManager) : fHash->getHashVal(key, fHashModulus, fMemoryManager);
     assert(hashVal < fHashModulus);
 
     // Search that bucket for the key
     RefHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
     while (curElem)
     {
-               if (fHash->equals(key, curElem->fKey))
+        if (fHash==0?XMLString::equals((const XMLCh*)key, (const 
XMLCh*)curElem->fKey) : fHash->equals(key, curElem->fKey))
             return curElem;
 
         curElem = curElem->fNext;
@@ -498,14 +492,14 @@
 findBucketElem(const void* const key, unsigned int& hashVal) const
 {
     // Hash the key
-    hashVal = fHash->getHashVal(key, fHashModulus, fMemoryManager);
+    hashVal = fHash==0?XMLString::hash((const XMLCh*)key, fHashModulus, 
fMemoryManager) : fHash->getHashVal(key, fHashModulus, fMemoryManager);
     assert(hashVal < fHashModulus);
 
     // Search that bucket for the key
     const RefHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
     while (curElem)
     {
-        if (fHash->equals(key, curElem->fKey))
+        if (fHash==0?XMLString::equals((const XMLCh*)key, (const 
XMLCh*)curElem->fKey) : fHash->equals(key, curElem->fKey))
             return curElem;
 
         curElem = curElem->fNext;
@@ -521,7 +515,7 @@
 RefHashTableOfEnumerator(RefHashTableOf<TVal>* const toEnum
                          , const bool adopt
                          , MemoryManager* const manager)
-       : fAdopted(adopt), fCurElem(0), fCurHash((unsigned int)-1), 
fToEnum(toEnum)
+    : fAdopted(adopt), fCurElem(0), fCurHash((unsigned int)-1), fToEnum(toEnum)
     , fMemoryManager(manager)
 {
     if (!toEnum)

Modified: xerces/c/trunk/src/xercesc/util/ValueHashTableOf.c
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/ValueHashTableOf.c?rev=650214&r1=650213&r2=650214&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/ValueHashTableOf.c (original)
+++ xerces/c/trunk/src/xercesc/util/ValueHashTableOf.c Mon Apr 21 10:56:39 2008
@@ -45,28 +45,28 @@
     , fHashModulus(modulus)
     , fHash(0)
 {
-       initialize(modulus);
-       // set hasher
-       fHash = hashBase;
+    initialize(modulus);
+    // set hasher
+    fHash = hashBase;
 }
 
 template <class TVal>
 ValueHashTableOf<TVal>::ValueHashTableOf( const unsigned int modulus
                                         , MemoryManager* const manager)
-       : fMemoryManager(manager)
+    : fMemoryManager(manager)
     , fBucketList(0)
     , fHashModulus(modulus)
     , fHash(0)
 {
-       initialize(modulus);
+    initialize(modulus);
 
-       // create default hasher
-       fHash = new (fMemoryManager) HashXMLCh();
+    // create default hasher
+    fHash = new (fMemoryManager) HashXMLCh();
 }
 
 template <class TVal> void ValueHashTableOf<TVal>::initialize(const unsigned 
int modulus)
 {
-       if (modulus == 0)
+    if (modulus == 0)
         ThrowXMLwithMemMgr(IllegalArgumentException, 
XMLExcepts::HshTbl_ZeroModulus, fMemoryManager);
 
     // Allocate the bucket list and zero them
@@ -83,7 +83,7 @@
 
     // Then delete the bucket list & hasher
     fMemoryManager->deallocate(fBucketList); //delete [] fBucketList;
-       delete fHash;
+    delete fHash;
 }
 
 
@@ -183,7 +183,7 @@
     if (newBucket)
     {
         newBucket->fData = valueToAdopt;
-               newBucket->fKey = key;
+        newBucket->fKey = key;
     }
      else
     {
@@ -210,7 +210,7 @@
     ValueHashTableBucketElem<TVal>* curElem = fBucketList[hashVal];
     while (curElem)
     {
-               if (fHash->equals(key, curElem->fKey))
+        if (fHash->equals(key, curElem->fKey))
             return curElem;
 
         curElem = curElem->fNext;
@@ -269,7 +269,7 @@
 
             // Delete the current element
             // delete curElem;
-                       // destructor is empty...
+            // destructor is empty...
             // curElem->~ValueHashTableBucketElem();
             fMemoryManager->deallocate(curElem);                        
 
@@ -295,7 +295,7 @@
 ValueHashTableOfEnumerator(ValueHashTableOf<TVal>* const toEnum
                            , const bool adopt
                            , MemoryManager* const manager)
-       : fAdopted(adopt), fCurElem(0), fCurHash((unsigned int)-1), 
fToEnum(toEnum), fMemoryManager(manager)
+    : fAdopted(adopt), fCurElem(0), fCurHash((unsigned int)-1), 
fToEnum(toEnum), fMemoryManager(manager)
 {
     if (!toEnum)
         ThrowXMLwithMemMgr(NullPointerException, 
XMLExcepts::CPtr_PointerIsZero, manager);

Modified: xerces/c/trunk/src/xercesc/util/XMLString.hpp
URL: 
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/XMLString.hpp?rev=650214&r1=650213&r2=650214&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLString.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLString.hpp Mon Apr 21 10:56:39 2008
@@ -270,14 +270,14 @@
       */
     static bool equals
     (
-          const XMLCh* const    str1
-        , const XMLCh* const    str2
+          const XMLCh* str1
+        , const XMLCh* str2
     );
 
     static bool equals
     (
-          const char* const    str1
-        , const char* const    str2
+          const char* str1
+        , const char* str2
     );
 
        /** Lexicographically compares <code>str1</code> and <code>str2</code>
@@ -1448,60 +1448,54 @@
        return true;
 }
 
-inline bool XMLString::equals(   const XMLCh* const    str1
-                               , const XMLCh* const    str2)
+inline bool XMLString::equals(   const XMLCh* str1
+                               , const XMLCh* str2)
 {
     if(str1==str2)
         return true;
 
-    const XMLCh* psz1 = str1;
-    const XMLCh* psz2 = str2;
-
-    if (psz1 == 0 || psz2 == 0) {
-        if ((psz1 != 0 && *psz1) || (psz2 != 0 && *psz2))
+    if (str1 == 0 || str2 == 0) {
+        if ((str1 != 0 && *str1) || (str2 != 0 && *str2))
             return false;
         else
             return true;
     }
 
-    while (*psz1 == *psz2)
+    while (*str1 == *str2)
     {
         // If either has ended, then they both ended, so equal
-        if (!*psz1)
+        if (!*str1)
             return true;
 
         // Move upwards for the next round
-        psz1++;
-        psz2++;
+        str1++;
+        str2++;
     }
     return false;
 }
 
-inline bool XMLString::equals(   const char* const    str1
-                               , const char* const    str2)
+inline bool XMLString::equals(   const char* str1
+                               , const char* str2)
 {
     if(str1==str2)
         return true;
 
-    const char* psz1 = str1;
-    const char* psz2 = str2;
-
-    if (psz1 == 0 || psz2 == 0) {
-        if ((psz1 != 0 && *psz1) || (psz2 != 0 && *psz2))
+    if (str1 == 0 || str2 == 0) {
+        if ((str1 != 0 && *str1) || (str2 != 0 && *str2))
             return false;
         else
             return true;
     }
 
-    while (*psz1 == *psz2)
+    while (*str1 == *str2)
     {
         // If either has ended, then they both ended, so equal
-        if (!*psz1)
+        if (!*str1)
             return true;
 
         // Move upwards for the next round
-        psz1++;
-        psz2++;
+        str1++;
+        str2++;
     }
     return false;
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to