diff options
author | Paolo Carlini <paolo@gcc.gnu.org> | 2004-05-18 15:58:33 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2004-05-18 15:58:33 +0000 |
commit | 2ab20654a24e909b0e44cf3b25e53e64a0a76193 (patch) | |
tree | ed15eac84fcc4b31104f3857ff3dd70bd32b03d7 /libstdc++-v3 | |
parent | 70315fcdde3a60e23d39586a9b5a237ff9334a9e (diff) | |
download | gcc-2ab20654a24e909b0e44cf3b25e53e64a0a76193.zip gcc-2ab20654a24e909b0e44cf3b25e53e64a0a76193.tar.gz gcc-2ab20654a24e909b0e44cf3b25e53e64a0a76193.tar.bz2 |
[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
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 12 | ||||
-rw-r--r-- | libstdc++-v3/include/ext/mt_allocator.h | 38 |
2 files changed, 35 insertions, 15 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 61d4e52..7ec7e3c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +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> * include/ext/enc_filebuf.h: Move concept-check macro to class scope. diff --git a/libstdc++-v3/include/ext/mt_allocator.h b/libstdc++-v3/include/ext/mt_allocator.h index 1fc0ccb..9737700 100644 --- a/libstdc++-v3/include/ext/mt_allocator.h +++ b/libstdc++-v3/include/ext/mt_allocator.h @@ -342,23 +342,32 @@ namespace __gnu_cxx __block->_M_next = reinterpret_cast<_Block_record*>(__c); __block = __block->_M_next; } + __block->_M_next = NULL; } else { - if (__block_count > __bin._M_free[0]) - __block_count = __bin._M_free[0]; - const size_t __added = __block_count; - _Block_record* __first = __bin._M_first[0]; - __block = __first; - --__block_count; - while (__block_count-- > 0) - __block = __block->_M_next; - __bin._M_first[0] = __block->_M_next; - __bin._M_free[0] -= __added; + // Is the number of required blocks greater than or + // equal to the number that can be provided by the + // global free list? + __bin._M_first[__thread_id] = __bin._M_first[0]; + if (__block_count >= __bin._M_free[0]) + { + __bin._M_free[__thread_id] = __bin._M_free[0]; + __bin._M_free[0] = 0; + __bin._M_first[0] = NULL; + } + 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); - - __bin._M_first[__thread_id] = __first; - __bin._M_free[__thread_id] += __added; } } else @@ -375,9 +384,8 @@ namespace __gnu_cxx __block->_M_next = reinterpret_cast<_Block_record*>(__c); __block = __block->_M_next; } + __block->_M_next = NULL; } - - __block->_M_next = NULL; } __block = __bin._M_first[__thread_id]; |