Path: csiph.com!weretis.net!feeder4.news.weretis.net!news.unit0.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail NNTP-Posting-Date: Thu, 08 Jun 2017 05:44:34 -0500 From: Gareth Owen Newsgroups: comp.lang.c Subject: Re: memscan() function or equivalent References: <20170607154705.f161b2807eb2b1a8dc12d389@gmail.com> <12fb0e96-0ac3-442d-8d04-baaef4234a85@googlegroups.com> <20170607164800.a6fba9d07170ec5d056d25a0@gmail.com> <878tl3g5jw.fsf@bsb.me.uk> <87wp8n4lqm.fsf@gmail.com> <87zidj9cfv.fsf@gmail.com> Date: Thu, 08 Jun 2017 11:44:34 +0100 Message-ID: <87ink6g3n1.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:/II8YGy6qhJOAZaEaNcVaNhaSW8= MIME-Version: 1.0 Content-Type: text/plain Lines: 13 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-zR6Qw6NKS5giNF+/lxE0pNXqjsvItOtOuS2KrLjf4hvt+98Q/4YSz4xysyV0qOo7IVJ0eMUTqh1BKYd!gk+SMLstq1kKSVdqkdzqlrVr0RhUN3yMG0QbktMDIHmW02yDT34CzMk442Yb56YcqUepl+s= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 1719 Xref: csiph.com comp.lang.c:111804 David Brown writes: > You have to have "(*b++ == c)", or the loop will exit rather quickly - > gcc is smart enough to do one check, and return 0 or n. *Facepalm* Thanks for doing it right! [interesting results and commentary snipped] So *if* its speed critical - you still need to measure, and profile, and possibly feed that profile information back to the optimiser. Except when you don't. :)