[BusyBox] [PATCH] Re: Sigh... this time i attached the file (bunzip-4.c)
Rob Landley
rob at landley.net
Wed Oct 22 10:23:16 UTC 2003
I'm going through Manuel's bunzip-4 optimization drop, and whipping up a patch
against CVS. I haven't really changed Manuel's code much, but I cleaned up
and fluffed out the comments tremendously. :)
I did a couple cleanups that shouldn't affect functionality, but should make
it easier to read. (Famous last words.) The one I'm not quite sure about is
how the assembly works out turning an if(--x) into if(x--)... that might
wind up being one extra instruction and slightly slower, I'm not sure. (If
so, it's easily revertible. It's just that when trying to detect a run
length of 3, counting down from 3 makes more sense than counting down from 4.
But it's not worth taking a speed or size hit...)
About the #warnings:
#warning should probably be "ssize_t read_bunzip(bunzip_data *,void *,size_t)"
No, it shouldn't. This is not an offset into a file, this is the size of a
memory buffer. A platform that can index a block of memory larger than its
integer size is _badly_designed_. We shouldn't need funky typedefs designed
to disguise the fact that ancient HP mainframes, which did all math as binary
coded decimal, also had to sacrifice a live chicken to access memory. So I
say "int" is correct.
Feel free to disagree with this, but I'd like to hear the rationale. :)
#warning check for EOF and trailing trash
I put that into the sample main, but really it belongs in the busybox
bunzip/bzcat command code that calls it. (Not really a decompress engine
issue.) A to-do item. :)
Here's the patch against CVS. It compiles to 6520 bytes, and decompresses the
kernel tarball on my laptop in a little under 65 seconds vs a little under 76
seconds for the original. :)
Rob
P.S. I also #ifdefed out the simple main so this can be used as a library
without having te edit the file. Compile ala "gcc -Os -D TESTING bunzip.c"
to enable standalone testing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bunzip-4.patch
Type: text/x-diff
Size: 26589 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20031022/15265aa8/attachment.bin
More information about the busybox
mailing list