aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2004-10-14 21:05:24 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2004-10-14 21:05:24 +0000
commit11aaaa84ae74f52ba9cb62ec6745c4b38f0247f9 (patch)
tree8dfe6ae36b4eea62bc05af4e0a631eb473549320
parented674251587d9dcc99e617713da9a992774d6b73 (diff)
downloadgcc-11aaaa84ae74f52ba9cb62ec6745c4b38f0247f9.zip
gcc-11aaaa84ae74f52ba9cb62ec6745c4b38f0247f9.tar.gz
gcc-11aaaa84ae74f52ba9cb62ec6745c4b38f0247f9.tar.bz2
mt_allocator.h: Tweaks.
2004-10-14 Benjamin Kosnik <bkoz@redhat.com> * include/ext/mt_allocator.h: Tweaks. * src/mt_allocator.cc: Same. From-SVN: r89052
-rw-r--r--libstdc++-v3/ChangeLog5
-rw-r--r--libstdc++-v3/include/ext/mt_allocator.h2
-rw-r--r--libstdc++-v3/src/mt_allocator.cc38
3 files changed, 23 insertions, 22 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 50c1da5..31a9db0 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2004-10-14 Benjamin Kosnik <bkoz@redhat.com>
+
+ * include/ext/mt_allocator.h: Tweaks.
+ * src/mt_allocator.cc: Same.
+
2004-10-14 Dhruv Matani <dhruvbird@gmx.net>
* ext/bitmap_allocator.h: Clean-up add/remove functions.
diff --git a/libstdc++-v3/include/ext/mt_allocator.h b/libstdc++-v3/include/ext/mt_allocator.h
index 115ade7..3bbfc79 100644
--- a/libstdc++-v3/include/ext/mt_allocator.h
+++ b/libstdc++-v3/include/ext/mt_allocator.h
@@ -705,7 +705,7 @@ namespace __gnu_cxx
// Already reserved.
typedef typename __pool_type::_Block_record _Block_record;
_Block_record* __block = __bin._M_first[__thread_id];
- __bin._M_first[__thread_id] = __bin._M_first[__thread_id]->_M_next;
+ __bin._M_first[__thread_id] = __block->_M_next;
__pool._M_adjust_freelist(__bin, __block, __thread_id);
const __pool_base::_Tune& __options = __pool._M_get_options();
diff --git a/libstdc++-v3/src/mt_allocator.cc b/libstdc++-v3/src/mt_allocator.cc
index 373217d..7dff273 100644
--- a/libstdc++-v3/src/mt_allocator.cc
+++ b/libstdc++-v3/src/mt_allocator.cc
@@ -89,6 +89,7 @@ namespace __gnu_cxx
{
// Round up to power of 2 and figure out which bin to use.
const size_t __which = _M_binmap[__bytes];
+ _Bin_record& __bin = _M_bin[__which];
const _Tune& __options = _M_get_options();
const size_t __bin_size = ((__options._M_min_bin << __which)
+ __options._M_align);
@@ -97,24 +98,23 @@ namespace __gnu_cxx
// Get a new block dynamically, set it up for use.
void* __v = ::operator new(__options._M_chunk_size);
_Block_record* __block = static_cast<_Block_record*>(__v);
- --__block_count;
- _Block_record* __tmp = __block;
- while (__block_count-- > 0)
+ __bin._M_first[__thread_id] = __block;
+ while (--__block_count > 0)
{
- char* __c = reinterpret_cast<char*>(__tmp) + __bin_size;
- __tmp->_M_next = reinterpret_cast<_Block_record*>(__c);
- __tmp = __tmp->_M_next;
+ char* __c = reinterpret_cast<char*>(__block) + __bin_size;
+ __block->_M_next = reinterpret_cast<_Block_record*>(__c);
+ __block = __block->_M_next;
}
- __tmp->_M_next = NULL;
+ __block->_M_next = NULL;
- // Update _Bin_record fields.
- _Bin_record& __bin = _M_bin[__which];
- __bin._M_first[__thread_id] = __block->_M_next;
_Block_address* __address = new _Block_address;
__address->_M_initial = __v;
__address->_M_next = __bin._M_address;
__bin._M_address = __address;
+ __block = __bin._M_first[__thread_id];
+ __bin._M_first[__thread_id] = __block->_M_next;
+
// NB: For alignment reasons, we can't use the first _M_align
// bytes, even when sizeof(_Block_record) < _M_align.
return reinterpret_cast<char*>(__block) + __options._M_align;
@@ -245,8 +245,7 @@ namespace __gnu_cxx
_Block_record* __first = __tmp;
__remove /= __options._M_freelist_headroom;
const long __removed = __remove;
- --__remove;
- while (__remove-- > 0)
+ while (--__remove > 0)
__tmp = __tmp->_M_next;
__bin._M_first[__thread_id] = __tmp->_M_next;
__bin._M_free[__thread_id] -= __removed;
@@ -308,11 +307,10 @@ namespace __gnu_cxx
__gthread_mutex_unlock(__bin._M_mutex);
void* __v = ::operator new(__options._M_chunk_size);
- __bin._M_first[__thread_id] = static_cast<_Block_record*>(__v);
+ __block = static_cast<_Block_record*>(__v);
__bin._M_free[__thread_id] = __block_count;
- --__block_count;
- __block = __bin._M_first[__thread_id];
- while (__block_count-- > 0)
+ __bin._M_first[__thread_id] = __block;
+ while (--__block_count > 0)
{
char* __c = reinterpret_cast<char*>(__block) + __bin_size;
__block->_M_next = reinterpret_cast<_Block_record*>(__c);
@@ -343,9 +341,8 @@ namespace __gnu_cxx
{
__bin._M_free[__thread_id] = __block_count;
__bin._M_free[0] -= __block_count;
- --__block_count;
__block = __bin._M_first[0];
- while (__block_count-- > 0)
+ while (--__block_count > 0)
__block = __block->_M_next;
__bin._M_first[0] = __block->_M_next;
__block->_M_next = NULL;
@@ -358,8 +355,7 @@ namespace __gnu_cxx
void* __v = ::operator new(__options._M_chunk_size);
__block = static_cast<_Block_record*>(__v);
__bin._M_first[0] = __block;
- --__block_count;
- while (__block_count-- > 0)
+ while (--__block_count > 0)
{
char* __c = reinterpret_cast<char*>(__block) + __bin_size;
__block->_M_next = reinterpret_cast<_Block_record*>(__c);
@@ -374,7 +370,7 @@ namespace __gnu_cxx
}
__block = __bin._M_first[__thread_id];
- __bin._M_first[__thread_id] = __bin._M_first[__thread_id]->_M_next;
+ __bin._M_first[__thread_id] = __block->_M_next;
if (__gthread_active_p())
{