From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp1.rz.uni-karlsruhe.de (Debian-exim@smtp1.rz.uni-karlsruhe.de [129.13.185.217]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id oBALALWd011479 for ; Fri, 10 Dec 2010 16:10:22 -0500 (EST) Received: from hekate.usta.de (asta-nat.asta.uni-karlsruhe.de [172.22.63.82]) by smtp1.rz.uni-karlsruhe.de with esmtp (Exim 4.63 #1) id 1PRAEO-00027T-Nq; Fri, 10 Dec 2010 22:10:20 +0100 Received: from donnerwolke.usta.de ([172.24.96.3]) by hekate.usta.de with esmtp (Exim 4.72) (envelope-from ) id 1PRAEO-00018z-Mc for tech@mdocml.bsd.lv; Fri, 10 Dec 2010 22:10:20 +0100 Received: from iris.usta.de ([172.24.96.5] helo=usta.de) by donnerwolke.usta.de with esmtp (Exim 4.69) (envelope-from ) id 1PRAEO-0008RA-LV for tech@mdocml.bsd.lv; Fri, 10 Dec 2010 22:10:20 +0100 Received: from schwarze by usta.de with local (Exim 4.72) (envelope-from ) id 1PRAEO-0005S5-AX for tech@mdocml.bsd.lv; Fri, 10 Dec 2010 22:10:20 +0100 Date: Fri, 10 Dec 2010 22:10:20 +0100 From: Ingo Schwarze To: tech@mdocml.bsd.lv Subject: Re: roff.c question Message-ID: <20101210211020.GC18607@iris.usta.de> References: <20101201212834.GA22990@iris.usta.de> <4CF77A2B.6020702@bsd.lv> <4CF79F45.6080105@bsd.lv> <20101202225019.GD12188@iris.usta.de> <20101203214929.GB28384@iris.usta.de> <4CFBAC80.1060004@bsd.lv> <20101208010527.GA25360@iris.usta.de> <4D01F5A4.8010300@bsd.lv> <20101210204513.GB18607@iris.usta.de> <20101210205203.GA30244@britannica.bec.de> X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20101210205203.GA30244@britannica.bec.de> User-Agent: Mutt/1.5.21 (2010-09-15) Hi Joerg, Joerg Sonnenberger wrote on Fri, Dec 10, 2010 at 09:52:03PM +0100: > On Fri, Dec 10, 2010 at 09:45:13PM +0100, Ingo Schwarze wrote: >> If we want to go into micro-optimization, we could do this: >> >> for (cp = *bufp + pos; *cp; cp++) { >> if ('\\' != *cp) >> continue; > ... or use a single strchr() call to start the search. Sure, that would be correct, and not even obfuscation. > For the typical case of medium long lines and no \, strchr > can operate mostly on dwords... Here is our implementation of strchr(): char * strchr(const char *p, int ch) { for (;; ++p) { if (*p == ch) return((char *)p); if (!*p) return((char *)NULL); } /* NOTREACHED */ } You mean, the compiler will optimize that into dword comparisons, but will not optimize this code: for (cp = *bufp + pos; *cp; cp++) { if ('\\' != *cp) continue; And the difference will buy us enough to warrant the extra function call? I doubt any of this is relevant, but i'm tempted to do some measurements... Yours, Ingo -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv