On Fri, 2005-04-22 at 15:17 -0400, Jeffrey Stedfast wrote:
> On Fri, 2005-04-22 at 19:15 +0100, Ross Burton wrote:
> > On Fri, 2005-04-22 at 13:59 -0400, Jeffrey Stedfast wrote:
> > > seems to me like you are trying to micro-optimise and that's a huge
> > > waste of time.
> > >
> > > do you have any profiling data showing that these changes make a
> > > difference?
> >
> > For a few minutes of time, this reduces the memory impact of libcamel
> > (and I've partial patches for libebook too) by moving constant data
> > to .rodata, which is shared between all processes. Considering e-d-s is
> > being used by more and more applications, surely this is a good thing.
>
> isn't it already read-only? that's what static means in this context.
static in that context means that the symbol is only available in that
compilation unit, but doesn't make any statements about the read/write
nature of the variable.
"static int i=1" is a writable integer which defaults to 1, where as a
"static const int i = 1" is a constant integer.
> I used dd to dump the appropriate subsection of libcamel-1.2.so and sure
> enough, every string (and more) that you added const to is already in
> there :)
The strings are in .rodata, as "" creates a constant string literal.
The main use of the patch is to move arrays from .data into .rodata,
such as datetok_table (256 4-byte integers) and the mXXX set (a number
of 256 byte arrays).
Changing a char* into a const char[] doesn't change the storage of the
characters themselves, but the pointer. A char* involves an extra
pointer initialisation and de-reference compared to a char[]. Feel free
to refuse the patches adding const to strings, but I feel they are
useful if only from a semantic point of view. They are constant
strings. so should be marked as such.
Ross
--
Ross Burton mail: ross burtonini com
jabber: ross burtonini com
www: http://www.burtonini.com./
PGP Fingerprint: 1A21 F5B0 D8D0 CFE3 81D4 E25A 2D09 E447 D0B4 33DF
Attachment:
signature.asc
Description: This is a digitally signed message part