Yahoo! Groups
Groups Home - Yahoo! - Account Info - Help

Ebates: Click here for cash back at 400+ stores!
Welcome, Guest Register - Sign In  
smalleiffel [ Join This Group! ]
  Home  
* Messages  
  Chat  
  Files  
  Bookmarks  
  Database  
  Polls  
  Calendar  
  Promote  
 
 
  owner = Owner 
  moderator = Moderator 
  online = Online 
 
 
Messages Messages Help
 Reply  |  Forward  |  View Source  |  Unwrap Lines 
 
  Message 2874 of 3449  |  Previous | Next  [ Up Thread ]  Message Index 
 
 Msg #
From:  Dominique Colnet <Dominique.Colnet@l...>
Date:  Sun Jan 14, 2001  10:00 am
Subject:  Re: Any ideas why this crashes

Friedrich Dominicus writes:
 > Hello Dominque here a patch for append in STRING.E simular to the
 > suggested.
 > 
 > It does not crash the sended example and seems to be extremly
 > efficient as pointed out by the other message. Feel free to add or
 > forget it ;-)
I take it (just done a minor modification to ensure the fact that 
capacity always holds the capacity of storage).
So here is the new release of STRING.append:

   append, append_string(other: STRING) is
         -- Append `other' to Current.
      require
	 other /= Void
      local
	 other_count, needed_capacity: INTEGER;
	 new_capacity : INTEGER;
      do
         other_count := other.count;
	 needed_capacity := count + other_count;
         if needed_capacity > capacity then
	    if capacity = 0 then
	       storage := storage.calloc(needed_capacity);
	       capacity := needed_capacity;
            else
	       new_capacity := 2 * capacity;
	       if needed_capacity > new_capacity then
		  storage := storage.realloc(capacity,needed_capacity);
		  capacity := needed_capacity;
	       else
		  storage := storage.realloc(capacity,new_capacity);
		  capacity := new_capacity;
	       end;
            end;
         end;
         storage.copy_at(count,other.storage,other_count);
         count := needed_capacity;
      end;


This is uniform with the allocation strategy of STRING.extend.
May be this strategy should also be applyed to prepend ...

Note for Arno Wagner (in charge of the next ELKS STRING): keep this 
strategy in mind !

Finally, I have also changed SmallEiffel/sys/runtime/gc_lib.c to 
free unused chunks of the ReSisable Object Chunk Free List (rsocfl).
As you have noticed, your version of STRING.append is extremely
efficient on thie execution scheme.
Thanks to all.

This will be available in a few days [Release -0.75 Beta#04 (Jan 14th 2001)].

-- 
--------------------------------------------------------------
Dominique.Colnet@l... -- UHP (Nancy 1) -- INRIA Lorraine
http://SmallEiffel.loria.fr  --  The GNU Eiffel Compiler
POST: Loria, B.P. 239,54506 Vandoeuvre les Nancy Cedex, FRANCE
Voice:+33 0383593079 Mobile: +33 0665362381 Fax:+33 0383413079


  Message 2874 of 3449  |  Previous | Next  [ Up Thread ]  Message Index 
 
 Msg #
 Reply  |  Forward  |  View Source  |  Unwrap Lines   


Copyright © 2001 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help