Re: [PATCH] wip: change ISSPACE to use ascii whitespace check.
Alejandro Colomar via Mutt-dev <[email protected]>
| Newsgroups | gmane.mail.mutt.devel |
|---|---|
| Message-ID | <trp2mhkxdbxzkgigxyuctbqizmcn743osfwsf7mi5fewxn4r3y@bj2olfzjlwns> |
Hi Ian, On Thu, Feb 19, 2026 at 12:25:24PM +0000, Ian Collier via Mutt-dev wrote: > On Thu, Feb 19, 2026 at 12:51:57PM +0100, Alejandro Colomar via Mutt-dev wrote: > > An inline function with that would be an alternative. A macro is more > > compact, though, and can be implemented as a one-liner. When > > implementing several of these, it can help readability of the entire set > > of APIs if they fit in a compact space and they are very similar: > > But in your implementation of this you've already pre-defined a macro > (streq) - why not predefine a macro or inline function called, say, > is_member, to do the work and then your macros for each indivdual case > can be trivial as well as more readable. > > > The strchrnul(3) version seems to have significantly less instructions. > > I see. But the point is moot if strchrnul is not implemented on the > system. In addition I think the intent is slightly less clear, but > maybe that's just me. The benefit of abstracting strchrnul(3) instead of is_member() is that strchrnul(3) is quasi-standard, so people know what it does without having to read its documentation --and even if you have to read the documentation, it's pretty easy to understand and remember forever--. Abstracting streq(3) is also trivial for readability. It has only one possible meaning. (And it is implemented in gnulib, and has a manual page, so people can even consult that.) is_member(), on the other hand, would be some function of ours that would have to be checked every now and then to remember exactly what it does. So, is_member() would hurt readability more than strchrnul(), IMO. I will later compare assembly of the is_member() version with an strchrnul() provided by us, but I expect it to be quite similar, so we'd be having more performance on most systems by using strchrnul(3) and then the performance wouldn't be worse on OpenBSD. Finally, at least to me, code without branches is more readable, as my brain doesn't have to branch. I find the code with strchrnul(3) more readable, once you get used to streq(3) and strchrnul(3). Have a lovely day! Alex > > imc -- <https://www.alejandro-colomar.es> Use port 80 (that is, <...:80/>).
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmmXBXUACgkQ64mZXMKQ wqlI+w//VsctWyx9uvZ3hf2x2okR68Qwmsb+NO1ccSLNoTS9UHRcGoFT+tcmjd3X kdI6EmJ39yPWjan0AjAK4ScEUqwsrG5+XAcN/fD28MSM9xzpmzN5ekzkFAgL9eQh w62dlQS/TMBcLnc7gFqipcKYB5KTs7EOuhz3fh7uLdkyfXjHx1OXGS9/knE/hTA4 OS2GVnz2OsD80nSOdEuhaVjyz72JTm1mQcPZY5m7MnOAE6zJBG0gHKq5stR9pkFH tia1Oka2F5wNaCF9I3xaDS0oKrX7788rLA1tXE5FwkmBo9psEjjFXbHpmbRStN5H 6Pp1TMhg/XnXY/35fl+kwdRJsj766RDg4XQy+Ed9jNoTjlDCBk38WWKJzFbyjVAN h01NrDzXRi4boaYFHUlXnZn5yU+ARqve9DUPjwXoTSnoZXYXPddTTgpU6kdBjYe3 Yb7dUkECmxmmxApkX/35RtkSepR7DB6RT7eINVLL+wfzXXvG5XwbNjXsm0hNaMRW io7pgNWpTEfPEXMPhhwWaAxvvew80ydDHTtDpCqj8EiyyU70VIkxIdwBcGmh1BlB 9Q2dvwW4MgZfUeLWLllDddHHYS6tD5Yy7/BA/QDFkb42ljAbrTiyDjXonVGbo8nz s2gfpFUeaYMQLqUWD+hI6M6j8Cg8BTQc0ZJGItV+F/HWyLTXWPw= =ZO9Y -----END PGP SIGNATURE-----