From owner-cvs-lib Tue Oct 17 22:27:29 1995 Return-Path: owner-cvs-lib Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id WAA27988 for cvs-lib-outgoing; Tue, 17 Oct 1995 22:27:29 -0700 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id WAA27969 ; Tue, 17 Oct 1995 22:27:19 -0700 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id PAA12213; Wed, 18 Oct 1995 15:26:50 +1000 Date: Wed, 18 Oct 1995 15:26:50 +1000 From: Bruce Evans Message-Id: <199510180526.PAA12213@godzilla.zeta.org.au> To: bde@zeta.org.au, davidg@Root.COM Subject: Re: cvs commit: src/lib/libc/stdlib getenv.c Cc: CVS-commiters@freefall.freebsd.org, cvs-lib@freefall.freebsd.org Sender: owner-cvs-lib@FreeBSD.org Precedence: bulk >>The __findenv() wart is now duplicated. It is inlined in getenv() and > I'm aware of that and it was quite intentional. getenv() is called often, >setenv() is rarely called. There is no reason to inline __findenv() for >setenv() and unsetenv(), and inlining it for all three cases would just >create yet one more copy. It was cheap to inline it for getenv() since it I messed the 3rd use in unsetenv(). >only required moving it within the file. If we are going to "fix" this, the >only thing I would accept would be to make getenv() completely self contained >(__findenv() does more than getenv() needs), and move __findenv() into >setenv.c and then make it static. This could be done by putting a `static inline char *ifinddev()' in a header file and outlining it in setenv.c: static char *ofinddev() { return iffinddev(); } I actually don't think it's worth inlining either __finddev() or strncmp(). The usual method of comparing the first character would eliminate about 25/26 of the failing calls to strncmp(), and getenv() isn't called all that often. Note that inlining is often a pessimization, but this doesn't show up in simple tests because the stuff being tested stays in the cache. In real use, inlined code often displaces more generally useful code (such as that for strncmp()) from the cache. The only time inlining is clearly best is when the inlined code is smaller than the code to call the function. Bruce