From owner-cvs-all Fri Apr 5 9:20:58 2002 Delivered-To: cvs-all@freebsd.org Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224]) by hub.freebsd.org (Postfix) with ESMTP id DA08537B423; Fri, 5 Apr 2002 09:20:48 -0800 (PST) Received: from aldan.algebra.com (localhost [127.0.0.1]) by aldan.algebra.com (8.12.2/8.12.2) with ESMTP id g35HK7nF011066; Fri, 5 Apr 2002 12:20:12 -0500 (EST) (envelope-from mi@aldan.algebra.com) Message-Id: <200204051720.g35HK7nF011066@aldan.algebra.com> Date: Fri, 5 Apr 2002 12:20:07 -0500 (EST) From: Mikhail Teterin Subject: Re: cvs commit: src/usr.bin/yacc main.c To: ticso@cicely8.cicely.de Cc: obrien@FreeBSD.org, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org In-Reply-To: <20020405111032.GM51284@cicely8.cicely.de> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 5 Apr, Bernd Walter wrote: > It's main - a *one time* code path. I'm all for adding performance, > but rarely used code should favour for readability and size. Readability, actually, suffers -- one is left wondering: "Why is strlen() used? Can its argument change -- what am I missing?" and spends more time reading it, not less. > Your suggestion is more complex and bigger. I think, the increase in size or complexity is negligeble... The second hunk (temp_form) makes the code actually smaller and simpler. The binary will be smaller, though -- also negligebly. > And finaly gcc with -O *knows* that strlen("some string") results in a > constant value. Only for const arguments. Which is not the case here -- the contents of temp_form is modified, and only the programmer knows (the compiler does not), that the mkstemp is going to leave the size intact. I plan to stop participating in this thread. The thing works one way or the other -- all I wanted was to call attention to a trend I'd rather I not see, but hey... -mi >> Index: main.c >> =================================================================== >> RCS file: /home/ncvs/src/usr.bin/yacc/main.c,v >> retrieving revision 1.19 >> diff -U2 -r1.19 main.c >> --- main.c 4 Apr 2002 22:15:56 -0000 1.19 >> +++ main.c 4 Apr 2002 22:41:35 -0000 >> @@ -302,9 +302,11 @@ >> const char *tmpdir; >> >> - if (!(tmpdir = getenv("TMPDIR"))) >> + if (!(tmpdir = getenv("TMPDIR"))) { >> tmpdir = _PATH_TMP; >> + len = sizeof _PATH_TMP - 1; >> + } else >> + len = strlen(tmpdir); >> >> - len = strlen(tmpdir); >> - i = len + strlen(temp_form) + 1; >> + i = len + sizeof temp_form; >> if (len && tmpdir[len-1] != '/') >> ++i; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message