List:Commits« Previous MessageNext Message »
From:Roy Lyseng Date:April 28 2011 12:51pm
Subject:Re: bzr commit into mysql-trunk branch (tor.didriksen:3318) WL#5774
View as plain text  
On 28.04.11 14.36, Tor Didriksen wrote:
> On 2011-04-28 14:05, Roy Lyseng wrote:

>>
>> 2. Initial size, and lazy allocation
>>
>> If you take initsize as part of the template, you do not need to have
>> reserve() as an externally visible function, the initial space will be set
>> when the object is constructed. It may also be used to delay allocation until
>> the first insertion, which is slightly more efficient for objects with zero
>> final size.
>>
>
> For this case, we want initial size == 0, and only allocate memory if we
> actually need it.
> I guess you are asking for "the size of the initial allocation if the initial
> size == 0"
> I would prefer to keep the interface/semantics as close to std::vector as possible,
> rather than introducing 'initial size' which really means 'initial size if we
> insert anything into the array'.

I prefer to think of it as "lazy allocation of the initial memory chunk", which 
is natural when you have separate allocation of the head object and the array 
object. Yes, there will be two extra lines in the documentation to explain the 
difference between this and std::vector.

But this is really no big deal...
>
>> 3. The name.
>>
>> I think that we should be able to come up with a better name than
>> Mem_root_array for the new class. The name should better reflect the
>> functionality that it provides, rather than being hung up with the
>> implementation detail of the mem_root. There may also after a while be a whole
>> set of such classes that rely on a dedicated memory allocator, so they might
>> need a good family name. Perhaps a namespace would we good for this?
>>
>> Unfortunately I do not have a good name suggestion ;)
>
> namespace memroot
> {
> class Array...
> }
>

Why not? Except that "memroot" sounds more like a variable name than a 
descriptive name of a set of classes...

Dynamic_array and Vector are alternatives to Array.

Roy

Thread
bzr commit into mysql-trunk branch (tor.didriksen:3318) WL#5774Tor Didriksen14 Apr
  • Re: bzr commit into mysql-trunk branch (tor.didriksen:3318) WL#5774Olav Sandstaa19 Apr
    • Re: bzr commit into mysql-trunk branch (tor.didriksen:3318) WL#5774Tor Didriksen20 Apr
    • Re: bzr commit into mysql-trunk branch (tor.didriksen:3318) WL#5774Roy Lyseng28 Apr
      • Re: bzr commit into mysql-trunk branch (tor.didriksen:3318) WL#5774Tor Didriksen28 Apr
        • Re: bzr commit into mysql-trunk branch (tor.didriksen:3318) WL#5774Roy Lyseng28 Apr