[systemd-devel] [PATCH v2] shared: rename hasprefix() to startswith(), which is functionally identical and removed

Lennart Poettering lennart at poettering.net
Fri Jul 12 09:00:38 PDT 2013


On Fri, 12.07.13 08:42, Shawn Landden (shawnlandden at gmail.com) wrote:

> as most (if not all) of the prefix strings are static, these will get
> forward constant propagation optimized into single memcmp() calls, which
> should be much better than the non-SIMD hand-rolled version.

They are functionally close, but not the same. I added this to the TODO
list because I'd like to see them merged one day, but it's not trivial
as your patch.

startswith() is not particularly optimized, but it has one major
benefit: it returns a pointer to the first char after the passed prefix,
which is actually hugely useful and used at various places. hasprefix()
is more efficient for static+const prefix strings.

(startswith() is also nicer if prefix is potentially large. But I figure
this property doesn't matter and is somethign we can get rid of)

It should be possible to merge both calls in one macro, and that's how
I'd like to see this fixed.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list