This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] Mt_alloc: use __bin._M_free[0]


Patch for the mt_allocator.h file.

This patch modifies the allocate() function.

Tested x86-Linux.


On Mon, 2004-05-17 at 01:27, Paolo Carlini wrote:
> Dhruv Matani wrote:
> 
> >Ok, maybe the 2nd one will have these, but just in case.
> >  
> >
> No, the 2nd one deals with another, completely unrelated issue.
> 
> >Looking at this part of the code, you could make the operation 
> >O(1), if the number of free blocks in the global free list is <= 
> >those required. Just reset the pointer to NULL for the global 
> >list, and set the next pointer of the current free list to the 
> >one of the global free list's old value.
> >  
> >
> I see what you mean: nice idea. Are you willing to prepare and test
> a patch implementing this?
> 
> Thanks,
> Paolo.
-- 
        -Dhruv Matani.
http://www.geocities.com/dhruvbird/

Proud to be a Vegetarian.
http://www.vegetarianstarterkit.com/
http://www.vegkids.com/vegkids/index.html

*** mt_allocator.h	2004-05-17 20:04:38.000000000 +0530
--- /home/dhruv/projects/new_libstdc++-v3/mt_allocator.h	2004-05-17 20:23:11.000000000 +0530
*************** namespace __gnu_cxx
*** 345,364 ****
  		}
  	      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;
! 		  __gthread_mutex_unlock(__bin._M_mutex);
! 
! 		  __bin._M_first[__thread_id] = __first;
! 		  __bin._M_free[__thread_id] += __added;
  		}
  	    }
  	  else
--- 345,376 ----
  		}
  	      else
  		{
! 		  // Are the number of required blocks greater than or
! 		  // equal to the number that can be provided by the
! 		  // global free list?
! 		  if (__block_count >= __bin._M_free[0])
! 		    {
! 		      __bin._M_first[__thread_id] = __bin._M_first[0];
! 		      __bin._M_free[__thread_id] = __bin._M_free[0];
! 		      __bin._M_first[0] = 0;
! 		      __bin._M_free[0] = 0;
! 		      __gthread_mutex_unlock(__bin._M_mutex);
! 		    }
! 		  else
! 		    {
! 		      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;
! 		      __gthread_mutex_unlock(__bin._M_mutex);
! 
! 		      __bin._M_first[__thread_id] = __first;
! 		      __bin._M_free[__thread_id] += __added;
! 		    }
  		}
  	    }
  	  else

Attachment: ChangeLog
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]