From cb2a534d005ed1bd45612f576e79ef447a20e9e8 Mon Sep 17 00:00:00 2001 From: rich_sposato Date: Wed, 28 Dec 2005 22:34:53 +0000 Subject: [PATCH] Replaced literal constants with class static data members. (for clarity) git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@387 7ec92016-0320-0410-acc4-a06ded1c099a --- src/SmallObj.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/SmallObj.cpp b/src/SmallObj.cpp index 8dfaeb5..de82a91 100644 --- a/src/SmallObj.cpp +++ b/src/SmallObj.cpp @@ -212,6 +212,12 @@ namespace Loki /// Iterator through const container of Chunks. typedef Chunks::const_iterator ChunkCIter; + /// Fewest # of objects managed by a Chunk. + static unsigned char MinObjectsPerChunk_; + + /// Most # of objects managed by a Chunk - never exceeds UCHAR_MAX. + static unsigned char MaxObjectsPerChunk_; + /// Number of bytes in a single block within a Chunk. std::size_t blockSize_; /// Number of blocks managed by each Chunk. @@ -282,6 +288,9 @@ namespace Loki }; + unsigned char FixedAllocator::MinObjectsPerChunk_ = 8; + unsigned char FixedAllocator::MaxObjectsPerChunk_ = UCHAR_MAX; + // Chunk::Init ---------------------------------------------------------------- bool Chunk::Init( std::size_t blockSize, unsigned char blocks ) @@ -553,8 +562,8 @@ void FixedAllocator::Initialize( std::size_t blockSize, std::size_t pageSize ) blockSize_ = blockSize; std::size_t numBlocks = pageSize / blockSize; - if (numBlocks > UCHAR_MAX) numBlocks = UCHAR_MAX; - else if ( numBlocks < 8 ) numBlocks = 8; + if ( numBlocks > MaxObjectsPerChunk_ ) numBlocks = MaxObjectsPerChunk_; + else if ( numBlocks < MinObjectsPerChunk_ ) numBlocks = MinObjectsPerChunk_; numBlocks_ = static_cast(numBlocks); assert(numBlocks_ == numBlocks); @@ -1182,6 +1191,9 @@ bool SmallObjAllocator::IsCorrupt( void ) const //////////////////////////////////////////////////////////////////////////////// // $Log$ +// Revision 1.20 2005/12/28 22:34:53 rich_sposato +// Replaced literal constants with class static data members. (for clarity) +// // Revision 1.19 2005/12/19 08:05:46 syntheticpp // remove warnings when NDEBUG is defined //