Commit 2ab20654 by Paolo Carlini

[multiple changes]

2004-05-18  Paolo Carlini  <pcarlini@suse.de>

	* include/ext/mt_allocator.h:(__mt_alloc::allocate): Minor
	tweaks.

2004-05-18  Dhruv Matani  <dhruvbird@gmx.net>

	* include/ext/mt_allocator.h:(__mt_alloc::allocate): Re-write
	allocation loop which removes blocks from the global free list
	from O(N) to O(1) when the required blocks are <= the number
	available.

From-SVN: r81992
parent 70315fcd
2004-05-18 Paolo Carlini <pcarlini@suse.de>
* include/ext/mt_allocator.h:(__mt_alloc::allocate): Minor
tweaks.
2004-05-18 Dhruv Matani <dhruvbird@gmx.net>
* include/ext/mt_allocator.h:(__mt_alloc::allocate): Re-write
allocation loop which removes blocks from the global free list
from O(N) to O(1) when the required blocks are <= the number
available.
2004-05-18 Jonathan Wakely <redi@gcc.gnu.org> 2004-05-18 Jonathan Wakely <redi@gcc.gnu.org>
* include/ext/enc_filebuf.h: Move concept-check macro to class scope. * include/ext/enc_filebuf.h: Move concept-check macro to class scope.
......
...@@ -342,23 +342,32 @@ namespace __gnu_cxx ...@@ -342,23 +342,32 @@ namespace __gnu_cxx
__block->_M_next = reinterpret_cast<_Block_record*>(__c); __block->_M_next = reinterpret_cast<_Block_record*>(__c);
__block = __block->_M_next; __block = __block->_M_next;
} }
__block->_M_next = NULL;
} }
else else
{ {
if (__block_count > __bin._M_free[0]) // Is the number of required blocks greater than or
__block_count = __bin._M_free[0]; // equal to the number that can be provided by the
const size_t __added = __block_count; // global free list?
_Block_record* __first = __bin._M_first[0]; __bin._M_first[__thread_id] = __bin._M_first[0];
__block = __first; if (__block_count >= __bin._M_free[0])
--__block_count; {
while (__block_count-- > 0) __bin._M_free[__thread_id] = __bin._M_free[0];
__block = __block->_M_next; __bin._M_free[0] = 0;
__bin._M_first[0] = __block->_M_next; __bin._M_first[0] = NULL;
__bin._M_free[0] -= __added; }
else
{
__bin._M_free[__thread_id] = __block_count;
__bin._M_free[0] -= __block_count;
--__block_count;
__block = __bin._M_first[0];
while (__block_count-- > 0)
__block = __block->_M_next;
__bin._M_first[0] = __block->_M_next;
__block->_M_next = NULL;
}
__gthread_mutex_unlock(__bin._M_mutex); __gthread_mutex_unlock(__bin._M_mutex);
__bin._M_first[__thread_id] = __first;
__bin._M_free[__thread_id] += __added;
} }
} }
else else
...@@ -375,9 +384,8 @@ namespace __gnu_cxx ...@@ -375,9 +384,8 @@ namespace __gnu_cxx
__block->_M_next = reinterpret_cast<_Block_record*>(__c); __block->_M_next = reinterpret_cast<_Block_record*>(__c);
__block = __block->_M_next; __block = __block->_M_next;
} }
__block->_M_next = NULL;
} }
__block->_M_next = NULL;
} }
__block = __bin._M_first[__thread_id]; __block = __bin._M_first[__thread_id];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment