On Fri, Jul 12, 2013 at 5:35 PM, Shawn Landden <[email protected]> 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.
> -#define hasprefix(s, prefix) (memcmp(s, prefix, strlen(prefix)) == 0) > +#define startswith(s, prefix) (memcmp(s, prefix, strlen(prefix)) == 0) What if 's' is shorter than 'prefix'? We should not access the possibly uninitialized memory? Also there are users like: e = startswith() which rely on the returned offset. That would go wrong now, right? I guess we need a smarter version of startswith, maybe one that behaves different for const values and uses __builtin_constant_p logic to compile-time optimize it. Kay _______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
