[interfacekit] Re: BBlockCache bug

On 2003-08-29 at 04:55:22 [+0200], Marcus Overhagen wrote:
> 
> > What one can do to optimize Save() is not to keep track of the used 
> > blocks.
> Yes, that's a pretty good idea.
> 
> > That way you simply check, whether the chunk of memory passed to Save() 
> > has
> > the right size and, if so, add it to your stack of free blocks. If not, 
> > or if
> > the cache has reached the maximal number of free blocks, the memory would
> > simply be freed. That way both Get() and Save() are O(1).
> 
> I already did that before reading your email :)
> I implemented it similar, but the freeing is done more agressive.
> It doesn't try to maintain a maximum count of free buffers, but
> of allocated buffers. We can change that if needed.

Yep, we probably should. As it is documented in the BeBook one could abuse 
the class for arbitrary de-/allocations. Or, at least you shouldn't handle 
blocks with a different block size the same way (i.e. don't touch 
fExcessBlocks when dealing with them).

CU, Ingo

Other related posts: