|
Boost-Commit : |
From: xushiweizh_at_[hidden]
Date: 2008-05-07 06:01:40
Author: xushiwei
Date: 2008-05-07 06:01:39 EDT (Wed, 07 May 2008)
New Revision: 45193
URL: http://svn.boost.org/trac/boost/changeset/45193
Log:
Use std::vector instead of std::deque as PriorityQ underlying container
Text files modified:
sandbox/memory/boost/memory/gc_alloc.hpp | 13 +++++++------
sandbox/memory/boost/memory/stl/queue.hpp | 6 +++---
sandbox/memory/libs/memory/test/test_basic/memory/performance.cpp | 10 ++++++----
3 files changed, 16 insertions(+), 13 deletions(-)
Modified: sandbox/memory/boost/memory/gc_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/gc_alloc.hpp (original)
+++ sandbox/memory/boost/memory/gc_alloc.hpp 2008-05-07 06:01:39 EDT (Wed, 07 May 2008)
@@ -22,8 +22,8 @@
#include "stl/queue.hpp" // NS_BOOST_MEMORY::priority_queue
#endif
-#if !defined(_DEQUE_) && !defined(_DEQUE)
-#include <deque> // std::deque
+#if !defined(_VECTOR_) && !defined(_VECTOR)
+#include <vector> // std::vector
#endif
NS_BOOST_MEMORY_BEGIN
@@ -151,7 +151,7 @@
return a->cbNodeSize < b->cbNodeSize;
}
};
- typedef std::deque<FreeMemHeader*> Container;
+ typedef std::vector<FreeMemHeader*> Container;
typedef NS_BOOST_MEMORY::priority_queue<FreeMemHeader*, Container, Pred> PriorityQ;
char* m_begin;
@@ -480,12 +480,13 @@
void* BOOST_MEMORY_CALL manage(void* p, destructor_t fn)
{
- DestroyInfo* pNode = (DestroyInfo*)p - 1;
+ MemHeaderEx* pNode = (MemHeaderEx*)p - 1;
BOOST_MEMORY_ASSERT(pNode->fnDestroy == fn);
+ BOOST_MEMORY_ASSERT(pNode->nodeType == nodeAlloced);
pNode->pPrev = m_destroyChain;
- m_destroyChain = (MemHeaderEx*)((char*)pNode - sizeof(MemHeader));
- m_destroyChain->nodeType = nodeAllocedWithDestructor;
+ pNode->nodeType = nodeAllocedWithDestructor;
+ m_destroyChain = pNode;
return p;
}
Modified: sandbox/memory/boost/memory/stl/queue.hpp
==============================================================================
--- sandbox/memory/boost/memory/stl/queue.hpp (original)
+++ sandbox/memory/boost/memory/stl/queue.hpp 2008-05-07 06:01:39 EDT (Wed, 07 May 2008)
@@ -12,8 +12,8 @@
#ifndef BOOST_MEMORY_STL_QUEUE_HPP
#define BOOST_MEMORY_STL_QUEUE_HPP
-#if !defined(_DEQUE_) && !defined(_DEQUE)
-#include <deque> // std::deque
+#if !defined(_VECTOR_) && !defined(_VECTOR)
+#include <vector> // std::vector
#endif
#if !defined(_FUNCTIONAL_) && !defined(_FUNCTIONAL)
@@ -35,7 +35,7 @@
// -------------------------------------------------------------------------
template <class Type,
- class Sequence = std::deque<Type>,
+ class Sequence = std::vector<Type>,
class Pred = std::less<Type> >
class priority_queue
{
Modified: sandbox/memory/libs/memory/test/test_basic/memory/performance.cpp
==============================================================================
--- sandbox/memory/libs/memory/test/test_basic/memory/performance.cpp (original)
+++ sandbox/memory/libs/memory/test/test_basic/memory/performance.cpp 2008-05-07 06:01:39 EDT (Wed, 07 May 2008)
@@ -183,19 +183,21 @@
void doGcAllocManually(LogT& log, int NAlloc, int PerAlloc)
{
+ const int PerAlloc1 = PerAlloc/2;
+ const int PerAlloc2 = PerAlloc - PerAlloc1;
int i;
NS_BOOST_DETAIL::performance_counter counter;
{
for (int j = 0; j < NAlloc; ++j)
{
boost::gc_alloc alloc(m_recycle);
- for (i = 0; i < PerAlloc/2; ++i)
+ for (i = 0; i < PerAlloc1; ++i)
p[i] = BOOST_NEW(alloc, int);
- for (i = 0; i < PerAlloc/2; ++i)
+ for (i = 0; i < PerAlloc1; ++i)
alloc.destroy(p[i]);
- for (i = 0; i < PerAlloc/2; ++i)
+ for (i = 0; i < PerAlloc2; ++i)
p[i] = BOOST_NEW(alloc, int);
- for (i = 0; i < PerAlloc/2; ++i)
+ for (i = 0; i < PerAlloc2; ++i)
alloc.destroy(p[i]);
}
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk