-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hrvoje Niksic wrote:
> Of course, the changes that introduce const without compromising
> maintainability, such as the constification of the Wp declaration in
> ftp-opie.c, are more than welcome.

Indeed. In fact, even if Diego doesn't submit a patch with just those
changes, I'll probably put just those ones in myself.

> bThe method described by Mart is one.
> For readers of this list, it boils down to turning:
> 
> static const char *foo[] = {"one", "two", "three" };
> 
> into:
> 
> static const char foo_data[] = "one\0two\0three";
> static const foo_ind[] = {0, 4, 8};
> 
> static const char *foo(int ind) {
>   return foo_data[foo_data + foo_ind[ind]];
> }

Note that you could also do all the pointer maths up-front, leaving
existing usage code the same, with something like:

  static const char foo_data[] = "one\0two\0three";
  static const char * const foo = {foo_data + 0, foo_data + 4,
    foo_data + 8};

But yeah, I don't really think it's worthwhile for us.

In fact, even if we do end up making a Wget-like library at some point,
to wrap around something like libcurl, I don't think I'd spend too much
time trying to optimize this sort of thing. Though using properly
constified data will still be important. :)

- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHo06G7M8hyUobTrERAof9AJ0alipt3l7IbrB3LIjgSsGBki0aagCfXlQ+
GmXOZgcVq9fz6UMyJT+xRfo=
=rAVe
-----END PGP SIGNATURE-----

Reply via email to