@@ -65,20 +65,20 @@ class CDynamicPool
6565 CDynamicPool ()
6666 {
6767 constexpr size_t initialSize = GrowStrategy::GetInitialSize ();
68- m_poolParts.emplace_back (std::make_unique<CDynamicPoolPart<PoolObjT>>( initialSize) );
68+ m_poolParts.emplace_back (initialSize);
6969 }
7070
7171 PoolObjT* AllocateItem ()
7272 {
7373 for (auto & pool : m_poolParts)
7474 {
75- if (pool-> HasFreeSize ())
76- return pool-> AllocateItem ();
75+ if (pool. HasFreeSize ())
76+ return pool. AllocateItem ();
7777 }
7878
7979 try
8080 {
81- return AllocateNewPart ()-> AllocateItem ();
81+ return AllocateNewPart (). AllocateItem ();
8282 }
8383 catch (const std::bad_alloc&)
8484 {
@@ -90,9 +90,9 @@ class CDynamicPool
9090 {
9191 for (auto & pool : m_poolParts)
9292 {
93- if (pool-> OwnsItem (item))
93+ if (pool. OwnsItem (item))
9494 {
95- pool-> RemoveItem (item);
95+ pool. RemoveItem (item);
9696 return ;
9797 }
9898 }
@@ -104,7 +104,7 @@ class CDynamicPool
104104 {
105105 std::size_t size = 0 ;
106106 for (auto & pool : m_poolParts)
107- size += pool-> GetCapacity ();
107+ size += pool. GetCapacity ();
108108
109109 return size;
110110 }
@@ -113,7 +113,7 @@ class CDynamicPool
113113 {
114114 std::size_t size = 0 ;
115115 for (auto & pool : m_poolParts)
116- size += pool-> GetUsedSize ();
116+ size += pool. GetUsedSize ();
117117
118118 return size;
119119 }
@@ -128,13 +128,13 @@ class CDynamicPool
128128 return false ;
129129 else if (currentSize < newSize)
130130 {
131- // Grown
131+ // Grow
132132 while (currentSize < newSize)
133133 {
134134 try
135135 {
136- auto * nextPart = AllocateNewPart ();
137- currentSize += nextPart-> GetCapacity ();
136+ auto & nextPart = AllocateNewPart ();
137+ currentSize += nextPart. GetCapacity ();
138138 }
139139 catch (const std::bad_alloc&)
140140 {
@@ -147,11 +147,11 @@ class CDynamicPool
147147 // Shrink
148148 while (true )
149149 {
150- auto * part = m_poolParts.back (). get ();
151- if (part-> GetUsedSize () != 0 )
150+ auto & part = m_poolParts.back ();
151+ if (part. GetUsedSize () != 0 )
152152 return false ;
153153
154- currentSize -= part-> GetCapacity ();
154+ currentSize -= part. GetCapacity ();
155155 if (currentSize < newSize)
156156 return false ;
157157
@@ -166,13 +166,13 @@ class CDynamicPool
166166 }
167167
168168private:
169- CDynamicPoolPart<PoolObjT>* AllocateNewPart ()
169+ CDynamicPoolPart<PoolObjT>& AllocateNewPart ()
170170 {
171171 const std::size_t nextSize = GrowStrategy::GetNextSize (m_poolParts.size ());
172- m_poolParts.emplace_back (std::make_unique<CDynamicPoolPart<PoolObjT>>( nextSize) );
173- return m_poolParts.back (). get () ;
172+ m_poolParts.emplace_back (nextSize);
173+ return m_poolParts.back ();
174174 }
175175
176176private:
177- std::vector<std::unique_ptr< CDynamicPoolPart<PoolObjT> >> m_poolParts;
177+ std::list< CDynamicPoolPart<PoolObjT>> m_poolParts;
178178};
0 commit comments