Hi, Kay!

On 08/21/13 at 12:05pm, Kay Sievers wrote:
> On Wed, Aug 21, 2013 at 8:36 AM, WANG Chao <chaow...@redhat.com> wrote:
> 
> > --- a/TODO
> > +++ b/TODO
> > @@ -96,8 +96,6 @@ Features:
> >
> > -* do we really need both hasprefix() and startswith()?
> 
> It needs a little bit more:
>   - the open-coded startswith seems really slow, it should not get more users
>   - hasprefix can no longer be compile-time optimized, which is not good

Apart from the overflow issue hasprefix has, may I ask why hasprefix
can't be complile-time optimized now? What changed?

> 
> We might want something like this:
>   http://lists.freedesktop.org/archives/systemd-devel/2013-July/011860.html

It looks like Lennart has already figured out an optimized startswith:

#define startswith(s, prefix) ({ \
        size_t _l; \
        _l = strlen(prefix); \
        strncmp(s, prefix, _l) == 0 ? s + _l : NULL; \
})

IMHO, using strncmp() is fast enough. What do you think?

Thanks!
WANG Chao
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to