Re: svn commit: r227812 - head/lib/libc/string

2011-11-27 Thread Dag-Erling Smørgrav
David Chisnall writes: > As to the | vs || issue - by all means change it to || if it fits > better with the FreeBSD style. In the general case I prefer to use | > to hint to the compiler and readers of the code that short-circuit > evaluation is not required and to remove a sequence point and ma

Re: svn commit: r227812 - head/lib/libc/string

2011-11-23 Thread Eitan Adler
On Thu, Nov 24, 2011 at 12:17 AM, Bruce Evans wrote: > Maybe my mail client (unmentionable) is messing up something.  This came > back with the quotes even more mangled than usual, especially for my > reply. Is this better? I use Gmail as my mailer, and I have a feeling it gets confused sometimes

Re: svn commit: r227812 - head/lib/libc/string

2011-11-23 Thread Bruce Evans
On Tue, 22 Nov 2011, Eitan Adler wrote: Meta comment: I should have sent this patch to -hackers prior to seeking approval to commit. I learned my lesson and will seek wider review before making such changes in the future. On Tue, Nov 22, 2011 at 6:21 AM, Bruce Evans wrote: I saw your email abou

Re: svn commit: r227812 - head/lib/libc/string

2011-11-23 Thread David Chisnall
On 22 Nov 2011, at 20:27, David Schultz wrote: > Benchmark or not, I think you'll have a very hard time finding a > single real program that routinely calls strcasecmp() with > identical pointers! I've seen this pattern very often. Often the linker is able to combine constant strings defined in

Re: svn commit: r227812 - head/lib/libc/string

2011-11-22 Thread Eitan Adler
On Tue, Nov 22, 2011 at 6:56 PM, Peter Wemm wrote: > On Tue, Nov 22, 2011 at 12:27 PM, David Schultz wrote: >> On Tue, Nov 22, 2011, Eitan Adler wrote: >>> The problem with profiling this type of change is that it is hard to >>> find a good representative benchmark. I could easily write code that

Re: svn commit: r227812 - head/lib/libc/string

2011-11-22 Thread Peter Wemm
On Tue, Nov 22, 2011 at 12:27 PM, David Schultz wrote: > On Tue, Nov 22, 2011, Eitan Adler wrote: >> The problem with profiling this type of change is that it is hard to >> find a good representative benchmark. I could easily write code that >> will show you that adding the equality check is a goo

Re: svn commit: r227812 - head/lib/libc/string

2011-11-22 Thread Doug Barton
On 11/22/2011 12:27 PM, David Schultz wrote: > On Tue, Nov 22, 2011, Eitan Adler wrote: >> The problem with profiling this type of change is that it is hard to >> find a good representative benchmark. I could easily write code that >> will show you that adding the equality check is a good idea or t

Re: svn commit: r227812 - head/lib/libc/string

2011-11-22 Thread David Schultz
On Tue, Nov 22, 2011, Eitan Adler wrote: > The problem with profiling this type of change is that it is hard to > find a good representative benchmark. I could easily write code that > will show you that adding the equality check is a good idea or that it > is a horrible idea. IMHO it saves enough

Re: svn commit: r227812 - head/lib/libc/string

2011-11-22 Thread John Baldwin
On Tuesday, November 22, 2011 10:33:32 am David Schultz wrote: > On Tue, Nov 22, 2011, Eitan Adler wrote: > > + /* use a bitwise or to avoid an additional branch instruction */ > > + if ((s1 == s2) | (n == 0)) > > + return (0); > > I think there are three issues with this. > > First

Re: svn commit: r227812 - head/lib/libc/string

2011-11-22 Thread Eitan Adler
Meta comment: I should have sent this patch to -hackers prior to seeking approval to commit. I learned my lesson and will seek wider review before making such changes in the future. On Tue, Nov 22, 2011 at 6:21 AM, Bruce Evans wrote: I saw your email about the style changes. I'd like to flesh out

Re: svn commit: r227812 - head/lib/libc/string

2011-11-22 Thread David Schultz
On Tue, Nov 22, 2011, David Schultz wrote: > First, the comment suggesting that using '|' instead of '||' isn't > correct; any reasonable compiler knows how to optimize > side-effect-free expressions like these. (The reverse > transformation, from the arithmetic expression to the boolean one, > is

Re: svn commit: r227812 - head/lib/libc/string

2011-11-22 Thread Andriy Gapon
on 22/11/2011 16:20 David Chisnall said the following: > the use of | tells a human reading the code that the order is unimportant I think that it tells that we are dealing with bit flags, not with logical operations. Which would be a lie^W^W an incorrect hint in this case (both to humans and com

Re: svn commit: r227812 - head/lib/libc/string

2011-11-22 Thread David Schultz
On Tue, Nov 22, 2011, Eitan Adler wrote: > + /* use a bitwise or to avoid an additional branch instruction */ > + if ((s1 == s2) | (n == 0)) > + return (0); I think there are three issues with this. First, the comment suggesting that using '|' instead of '||' isn't correct; an

Re: svn commit: r227812 - head/lib/libc/string

2011-11-22 Thread David Chisnall
On 22 Nov 2011, at 11:21, Bruce Evans wrote: > If this optimization were any good, then the compiler would already do > it. In fact, gcc-4.2.1 already does it -- the reverse of it -- it rewrites: > > "if ((i == 0) | (j == 0)) return; test();" > > into: > > "if (i == 0 || j == 0) re

Re: svn commit: r227812 - head/lib/libc/string

2011-11-22 Thread Bruce Evans
On Mon, 21 Nov 2011 m...@freebsd.org wrote: On Mon, Nov 21, 2011 at 6:50 PM, Eitan Adler wrote: Author: eadler (ports committer) Date: Tue Nov 22 02:50:24 2011 New Revision: 227812 URL: http://svn.freebsd.org/changeset/base/227812 Log: ?- fix some style(9) nits with my last commit ?- add a co

Re: svn commit: r227812 - head/lib/libc/string

2011-11-21 Thread mdf
On Mon, Nov 21, 2011 at 6:50 PM, Eitan Adler wrote: > Author: eadler (ports committer) > Date: Tue Nov 22 02:50:24 2011 > New Revision: 227812 > URL: http://svn.freebsd.org/changeset/base/227812 > > Log: >  - fix some style(9) nits with my last commit >  - add a comment explaining why I used '|' i

svn commit: r227812 - head/lib/libc/string

2011-11-21 Thread Eitan Adler
Author: eadler (ports committer) Date: Tue Nov 22 02:50:24 2011 New Revision: 227812 URL: http://svn.freebsd.org/changeset/base/227812 Log: - fix some style(9) nits with my last commit - add a comment explaining why I used '|' instead of '||' Submitted by: danfe@ Approved by: emaste@