This is what I love about coding. We'll play with optimizing some of the simplest and least important things on a whim. May the winds of hackerdom ever be in your favor.
On July 3, 2020 3:34:23 AM EDT, Bernd Petrovitsch <[email protected]> wrote: >On Fri, 2020-07-03 at 08:12 +0200, Tito wrote: >[...] >> Improved version: >> >> char* last_char_is(const char *s, int c) { >> if (!s || !*s) return NULL; >> while (*(s + 1))s++; >> return (c == *s) ? (char *)s : NULL; >> } > >I like that;-) > >> or if you like gotos: >> >> char* FAST_FUNC last_char_is(const char *s, int c) >> { >> if (!s || !*s) goto OUT; >> while (*(s + 1))s++; >> if (c == *s) return (char *) s; >> OUT: >> return NULL; >> } >> >> bloatcheck is same for both: > >Both produce probably the sam asm output anyways ... > >> function old new >delta >> last_char_is 53 42 >-11 >> >------------------------------------------------------------------------------ >> (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-11) Total: >-11 bytes >> text data bss dec hex filename >> 980860 16891 1872 999623 f40c7 busybox_old >> 980849 16891 1872 999612 f40bc busybox_unstripped > >MfG, > Bernd _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
