Re: Is GStringChunk still useful?



On Mon, 2006-11-06 at 22:28 -0500, mark mark mielke cc wrote:
> On Mon, Nov 06, 2006 at 08:55:49PM -0600, Hans Petter Jansson wrote:

> > I seriously doubt that GStringChunk is useful, because the gain from
> > using non-aligned memory is lost if your strings don't fit the block
> > size (e.g. too long strings as described by Jeff, or even just the last
> > block not being completely filled). I'm in favor of obsoleting
> > GStringChunk.

> If true, then you should be able to prove it, and nothing is preventing
> GStringChunk from returning aligned memory.
> 
> Are you guessing?

As stated, it depends on the use case.

> > We could introduce a function:
> > g_pack_strings (&mail->from, &mail->to, &mail->cc, &mail->subject,
> > &mail->body, NULL);
> 
> > Which would strlen() the strings, allocate a block which would fit the
> > strings perfectly, copy the strings into the block, free the original
> > strings and replace the passed-in pointers with the strings' new
> > locations in the block. The block could be freed thusly:

> I suspect this would defeat the purpose of using it in the first place.
> How is mail->from allocated? If using an allocate function, and then
> re-packing, all you are saving is space. Not allocation time. Space is
> probably irrelevant in most applications. Allocation time, especially
> in a multi-threaded context with synchronization on the free memory
> pools, is not irrelevant.

That's why I said long-lived. If the data is allocated and kept around
for a long time, the space saved is more important than the CPU time
lost.

-- 
Hans Petter




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]