Alejandro Colomar via Mutt-dev wrote in <af3iSKUNg12ZOG-6@devuan>: ... |I'd like to see evidence that compilers are unable to perform this |optimization these days. Most likely, they know about strspn(3) and |optimize it as much as you could with a manual loop.
Only as a somewhat uninteresting generic remark. We had implemented similar functionality with a (very much inlined, template-based) bitset (over 25 years ago). As in loop over, set bits, loop over, test bits. |But even if I saw evidence (which I doubt), I think the fact that it |doesn't allow silly mistakes when writing the loop already counters the |small efficiency theoretical gains. (And i still think this is a good solution for longer strings, especially so longer/longer, so to say. It thus would require a non-portable, still not standardized, __builtin_constant_p() dance to go for alternative all-inline maybe even assembler optimized approaches for short strings.) I do not know whether it is right to loose backward compatibility and -- to be tested -- backward efficiency in the way you propose it; my own feeling is "yes it is". It likely is ok for mutt, or the Linux kernel, or what. --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)
