object.reserve() and array size
    Lars T. Kyllingstad 
    public at kyllingen.NOSPAMnet
       
    Wed Jul 14 03:01:10 PDT 2010
    
    
  
Is object.reserve() only useful for large arrays, or should I always use 
it if I intend to append to an array?
Let's say I want to read some data, and I expect there to be ~100 bytes 
of data.  Is there any point in using reserve() first, or will there 
always be that much memory available to an array?
  byte[] buffer;
  buffer.reserve(100);
  foreach(byte b; dataSource) buffer ~= b;
-Lars
    
    
More information about the Digitalmars-d-learn
mailing list