mhoyt 2004/09/07 14:52:11
Modified: c/Projects/Win32/VC7.1/AllInOne AllInOne.vcproj
AllInOneWithICU.vcproj
c/src/xalanc/Include XalanList.hpp XalanMap.hpp
c/src/xalanc/PlatformSupport ArenaAllocator.hpp
ReusableArenaAllocator.hpp XalanArrayAllocator.hpp
Log:
XalanList integration as well as improvements to XalanList/XalanMap to avoid
memory allocation in the 'default' construtor
Revision Changes Path
1.5 +3 -0 xml-xalan/c/Projects/Win32/VC7.1/AllInOne/AllInOne.vcproj
Index: AllInOne.vcproj
===================================================================
RCS file:
/home/cvs/xml-xalan/c/Projects/Win32/VC7.1/AllInOne/AllInOne.vcproj,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AllInOne.vcproj 31 Aug 2004 14:20:26 -0000 1.4
+++ AllInOne.vcproj 7 Sep 2004 21:52:11 -0000 1.5
@@ -260,6 +260,9 @@
RelativePath="..\..\..\..\src\xalanc\Include\XalanAutoPtr.hpp">
</File>
<File
+
RelativePath="..\..\..\..\src\xalanc\Include\XalanList.hpp">
+ </File>
+ <File
RelativePath="..\..\..\..\src\xalanc\Include\XalanMap.hpp">
</File>
<File
1.5 +3 -0
xml-xalan/c/Projects/Win32/VC7.1/AllInOne/AllInOneWithICU.vcproj
Index: AllInOneWithICU.vcproj
===================================================================
RCS file:
/home/cvs/xml-xalan/c/Projects/Win32/VC7.1/AllInOne/AllInOneWithICU.vcproj,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AllInOneWithICU.vcproj 31 Aug 2004 14:20:26 -0000 1.4
+++ AllInOneWithICU.vcproj 7 Sep 2004 21:52:11 -0000 1.5
@@ -254,6 +254,9 @@
RelativePath="..\..\..\..\src\xalanc\Include\XalanAutoPtr.hpp">
</File>
<File
+
RelativePath="..\..\..\..\src\xalanc\Include\XalanList.hpp">
+ </File>
+ <File
RelativePath="..\..\..\..\src\xalanc\Include\XalanMap.hpp">
</File>
<File
1.2 +34 -22 xml-xalan/c/src/xalanc/Include/XalanList.hpp
Index: XalanList.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/Include/XalanList.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XalanList.hpp 2 Sep 2004 21:43:22 -0000 1.1
+++ XalanList.hpp 7 Sep 2004 21:52:11 -0000 1.2
@@ -180,52 +180,55 @@
XalanList(
MemoryManagerType* theManager = 0) :
m_memoryManager(theManager),
- m_listHead(createFirstNode()),
+ m_listHead(0),
m_freeListHeadPtr(0)
{
}
~XalanList()
{
- iterator pos = begin();
- while (pos != end())
+ if (m_listHead != 0)
{
- destroyNode(pos++.node());
- }
+ iterator pos = begin();
+ while (pos != end())
+ {
+ destroyNode(pos++.node());
+ }
+
+ Node * freeNode = m_freeListHeadPtr;
+ while (freeNode != 0)
+ {
+ Node * nextNode = freeNode->next;
+ deallocate(freeNode);
+ freeNode = nextNode;
+ }
- Node * freeNode = m_freeListHeadPtr;
- while (freeNode != 0)
- {
- Node * nextNode = freeNode->next;
- deallocate(freeNode);
- freeNode = nextNode;
+ deallocate(m_listHead);
}
-
- deallocate(m_listHead);
}
iterator
begin()
{
- return iterator(*m_listHead->next);
+ return iterator(*(getListHead().next));
}
const_iterator
begin() const
{
- return const_iterator(*m_listHead->next);
+ return const_iterator(*(getListHead().next));
}
iterator
end()
{
- return iterator(*m_listHead);
+ return iterator(getListHead());
}
const_iterator
end() const
{
- return const_iterator(*m_listHead);
+ return const_iterator(getListHead());
}
reverse_iterator
@@ -417,12 +420,21 @@
deallocate(&node);
}
- Node* createFirstNode()
+ Node& getListHead()
+ {
+ if (0 == m_listHead)
+ {
+ m_listHead = allocate(1);
+ m_listHead->next = m_listHead;
+ m_listHead->prev = m_listHead;
+ }
+
+ return *m_listHead;
+ }
+
+ Node& getListHead() const
{
- Node* newNode = allocate(1);
- newNode->next = newNode;
- newNode->prev = newNode;
- return newNode;
+ return const_cast<XalanList*>(this)->getListHead();
}
Node*
1.5 +33 -39 xml-xalan/c/src/xalanc/Include/XalanMap.hpp
Index: XalanMap.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/xalanc/Include/XalanMap.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XalanMap.hpp 4 Sep 2004 03:19:07 -0000 1.4
+++ XalanMap.hpp 7 Sep 2004 21:52:11 -0000 1.5
@@ -24,7 +24,6 @@
#include <cstddef>
-#include <list>
#include <algorithm>
#include <functional>
#include <utility>
@@ -36,6 +35,7 @@
#include <xalanc/Include/XalanVector.hpp>
+#include <xalanc/Include/XalanList.hpp>
@@ -120,7 +120,7 @@
}
};
- typedef XALAN_STD_QUALIFIER list<Entry>
EntryListType;
+ typedef XalanList<Entry>
EntryListType;
typedef typename EntryListType::iterator
EntryListIterator;
typedef typename EntryListType::const_iterator
EntryListConstIterator;
@@ -202,12 +202,14 @@
XalanMap(
float loadFactor = 0.75,
+ size_type minBuckets = 10,
MemoryManagerType* theMemoryManager = 0) :
m_memoryManager(theMemoryManager),
m_loadFactor(loadFactor),
+ m_minBuckets(minBuckets),
m_size(0),
m_entries(/* m_memoryManager */),
- m_buckets(10, m_entries.end(), m_memoryManager),
+ m_buckets(m_memoryManager),
m_freeList()
{
}
@@ -215,6 +217,7 @@
XalanMap(const XalanMap &theRhs) :
m_memoryManager(theRhs.m_memoryManager),
m_loadFactor(theRhs.m_loadFactor),
+ m_minBuckets(10),
m_size(0),
m_entries(/* m_memoryManager */),
m_buckets(size_type(m_loadFactor * theRhs.size())+ 1,
m_entries.end(), m_memoryManager),
@@ -273,18 +276,21 @@
iterator find(const key_type& key)
{
- size_type index = doHash(key);
+ if (!m_buckets.empty())
+ {
+ size_type index = doHash(key);
- EntryListIterator bucketPos = m_buckets[index];
+ EntryListIterator bucketPos = m_buckets[index];
- while (bucketPos != m_entries.end() &&
- bucketPos->bucketIndex == index)
- {
- if (m_equals(key,bucketPos->first))
+ while (bucketPos != m_entries.end() &&
+ bucketPos->bucketIndex == index)
{
- return iterator(*this,bucketPos);
+ if (m_equals(key,bucketPos->first))
+ {
+ return iterator(*this,bucketPos);
+ }
+ ++bucketPos;
}
- ++bucketPos;
}
return end();
@@ -292,21 +298,7 @@
const_iterator find(const key_type& key) const
{
- size_type index = doHash(key);
-
- EntryListConstIterator bucketPos = m_buckets[index];
-
- while (bucketPos != m_entries.end() &&
- bucketPos->bucketIndex == index)
- {
- if (m_equals(key,bucketPos->first))
- {
- return const_iterator(*this,bucketPos);
- }
- ++bucketPos;
- }
-
- return end();
+ return const_cast<ThisType *>(this)->find(key);
}
data_type & operator[](const key_type& key)
@@ -386,6 +378,11 @@
iterator doCreateEntry(const key_type & key, const data_type& data)
{
+ if (m_buckets.empty())
+ {
+ m_buckets.insert(m_buckets.begin(), m_minBuckets,
m_entries.end());
+ }
+
if (size_type(m_loadFactor * size()) > m_buckets.size())
{
rehash();
@@ -421,16 +418,16 @@
return iterator(*this, bucketStartPos);
}
- void doRemoveEntry(const EntryListIterator & toRemoveIter)
+ void doRemoveEntry(const EntryListIterator & toRemovePos)
{
- size_type index = toRemoveIter->bucketIndex;
- EntryListIterator nextPosition =
++(EntryListIterator(toRemoveIter));
+ size_type index = toRemovePos->bucketIndex;
+ EntryListIterator nextPos = ++(EntryListIterator(toRemovePos));
- if (m_buckets[index] == toRemoveIter)
+ if (m_buckets[index] == toRemovePos)
{
- if (nextPosition->bucketIndex == index)
+ if (nextPos->bucketIndex == index)
{
- m_buckets[index] = nextPosition;
+ m_buckets[index] = nextPos;
}
else
{
@@ -438,7 +435,7 @@
}
}
- m_freeList.splice(m_freeList.begin(), m_entries, toRemoveIter,
nextPosition);
+ m_freeList.splice(m_freeList.begin(), m_entries, toRemovePos,
nextPos);
--m_size;
}
@@ -451,11 +448,7 @@
{
EntryPosVectorType temp(size_type(1.6 * size()),
m_entries.end(), m_memoryManager);
m_buckets.swap(temp);
- doRehashEntries();
- }
-
- void doRehashEntries()
- {
+
EntryListType tempEntryList;
tempEntryList.splice(tempEntryList.begin(),m_entries,
m_entries.begin(), m_entries.end());
@@ -479,7 +472,6 @@
}
}
}
-
// Data members...
Hash m_hash;
@@ -489,6 +481,8 @@
MemoryManagerType* m_memoryManager;
float m_loadFactor;
+
+ size_type m_minBuckets;
size_type m_size;
1.6 +5 -6 xml-xalan/c/src/xalanc/PlatformSupport/ArenaAllocator.hpp
Index: ArenaAllocator.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/xalanc/PlatformSupport/ArenaAllocator.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ArenaAllocator.hpp 5 Jul 2004 14:53:51 -0000 1.5
+++ ArenaAllocator.hpp 7 Sep 2004 21:52:11 -0000 1.6
@@ -20,7 +20,10 @@
#include <algorithm>
-#include <list>
+
+
+
+#include <xalanc/Include/XalanList.hpp>
@@ -195,11 +198,7 @@
protected:
// data members...
-#if defined(XALAN_NO_STD_NAMESPACE)
- typedef list<ArenaBlockType*> ArenaBlockListType;
-#else
- typedef std::list<ArenaBlockType*> ArenaBlockListType;
-#endif
+ typedef XalanList<ArenaBlockType*> ArenaBlockListType;
size_type m_blockSize;
1.6 +1 -7
xml-xalan/c/src/xalanc/PlatformSupport/ReusableArenaAllocator.hpp
Index: ReusableArenaAllocator.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/xalanc/PlatformSupport/ReusableArenaAllocator.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ReusableArenaAllocator.hpp 5 Jul 2004 14:53:51 -0000 1.5
+++ ReusableArenaAllocator.hpp 7 Sep 2004 21:52:11 -0000 1.6
@@ -20,7 +20,6 @@
#include <algorithm>
-#include <list>
@@ -46,12 +45,7 @@
typedef ArenaAllocator<ObjectType,
ReusableArenaBlockType>
BaseClassType;
-#if defined (XALAN_NO_STD_NAMESPACE)
- typedef list<ReusableArenaBlockType*>
ArenaBlockListType;
-
-#else
- typedef std::list<ReusableArenaBlockType*>
ArenaBlockListType;
-#endif
+ typedef XalanList<ReusableArenaBlockType*>
ArenaBlockListType;
typedef typename ArenaBlockListType::iterator
iterator;
typedef typename ArenaBlockListType::const_iterator
const_iterator;
1.6 +2 -2
xml-xalan/c/src/xalanc/PlatformSupport/XalanArrayAllocator.hpp
Index: XalanArrayAllocator.hpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/src/xalanc/PlatformSupport/XalanArrayAllocator.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XalanArrayAllocator.hpp 31 Jul 2004 06:05:04 -0000 1.5
+++ XalanArrayAllocator.hpp 7 Sep 2004 21:52:11 -0000 1.6
@@ -23,12 +23,12 @@
#include <cassert>
-#include <list>
#include <utility>
#include <xalanc/Include/XalanVector.hpp>
+#include <xalanc/Include/XalanList.hpp>
@@ -45,7 +45,7 @@
typedef typename VectorType::size_type size_type;
typedef XALAN_STD_QUALIFIER pair<size_type, VectorType>
ListEntryType;
- typedef XALAN_STD_QUALIFIER list<ListEntryType>
ListType;
+ typedef XalanList<ListEntryType>
ListType;
typedef Type
value_type;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]