reduce the size of busybox
Rob Landley
rob at landley.net
Mon Jun 12 12:07:44 PDT 2006
On Monday 12 June 2006 2:58 pm, Bernhard Fischer wrote:
> On Mon, Jun 12, 2006 at 06:36:29PM +0200, Bernhard Fischer wrote:
> >On Mon, Jun 12, 2006 at 10:17:11AM -0400, Rob Landley wrote:
> >>Hopefully _this_ is going to merge strings. :)
> >
> >I doubt that.
>
> Just to reiterate:
> The problem is that you currently cannot do automatic substring merging.
> Our "normal" strings are properly merged, while these two examples are
> simply not equal:
>
> "foo"
> "foo\nbar"
>
> So we end up with both strings, each with it's full length.
> They _are_ in .rodata.str (depending on where they are used of course).
>
> That's why it helps if we say
> sub="foo%s"
> foo = sub, ""
> foobar = sub,"\nbar"
> because there we can obviously reuse 'sub', so save the dups.
Right now the compiler isn't doing the _easy_ substring merges, which is
simply broken.
Chopping up our code so that it's unintelligible and unmaintainable is a
separate issue. In each of those cases, before adding extra complexity in an
attempt to preserve the way things are currently done, I try to ask "do we
need that at all", and "is there a larger chunk of stuff that could be
refactored to avoid having to do this", and "is there some common way to do
this so we only have to learn this _once_".
Ugly solutions should be a last resort. There's lots of low-hanging fruit in
the tree to make things smaller, and the sort of thing you just suggested
makes the code more brittle and _less_ easy to shrink in general.
Rob
--
Never bet against the cheap plastic solution.
More information about the busybox
mailing list