[BusyBox] small libbb "get last path component" improvement

Manuel Novoa III mjn3 at busybox.net
Mon Dec 3 08:38:16 UTC 2001


Aaron,

On Sat, Dec 01, 2001 at 02:08:48AM -0800, Aaron Lehmann wrote:
> This removes an unnecessary variable and an unnecessary assignment
> from libbb/get_last_path_component.c.
> 
> I haven't noticed a tangible size change, but it may help on some
> arch's. The code output definately changed (I looked at the generated
> assembly, and the new version was 5 lines shorter).
> 
> Not tested, but it looks logically sound.

Ugh... this function really needs rewriting.  The attached version does
everything needed in one pass instead of traversing the string twice
using three different loops.  Size reduction is about 40%.

Also, as Erik mentioned to me that this is supposed to emulate basename(),
you can get that behavior (affects handling of NULL and "") by setting the
define appropriately.  Note that this changes the return value for "".
I don't know if that is ever an issue for any of the busybox callers.

Manuel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: glpc.c
Type: text/x-csrc
Size: 523 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20011203/947dcc3e/attachment.c 


More information about the busybox mailing list