[PATCH] libbb/last_char_is: rewrite for smaller and faster code

Kang-Che Sung explorer09 at gmail.com
Thu Jul 2 17:42:18 UTC 2020


On Friday, July 3, 2020, Jody Bruchon <jody at jodybruchon.com> wrote:
>
>
> On July 2, 2020 11:29:06 AM EDT, Kang-Che Sung <explorer09 at gmail.com>
wrote:
>>On Thursday, July 2, 2020, Jody Bruchon <jody at jodybruchon.com> wrote:
>>>  /* Find out if the last character of a string matches the one given
>>*/
>>> -char* FAST_FUNC last_char_is(const char *s, int c)
>>> +char* FAST_FUNC last_char_is(char *s, char c)
>>
>>Why are you removing the const qualifier, and how would that reduce the
>>code size?
>
> Why does it need the const in the first place? The code I wrote does
reduce the code size.

Any pointer parameter whose content is meant to be read-only is good to be
declared const. It's a compiler safety check that you won't accidentally
modify the content there. The const qualifier by itself doesn't add code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20200703/d9926ff7/attachment.html>


More information about the busybox mailing list