From owner-freebsd-hackers Mon Dec 18 10:31:15 2000 From owner-freebsd-hackers@FreeBSD.ORG Mon Dec 18 10:31:10 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from gw.nectar.com (gw.nectar.com [208.42.49.153]) by hub.freebsd.org (Postfix) with ESMTP id C644E37B69B for ; Mon, 18 Dec 2000 10:31:09 -0800 (PST) Received: from hamlet.nectar.com (hamlet.nectar.com [10.0.1.102]) by gw.nectar.com (Postfix) with ESMTP id 5FD7E193E1; Mon, 18 Dec 2000 12:31:08 -0600 (CST) Received: (from nectar@localhost) by hamlet.nectar.com (8.11.1/8.9.3) id eBIIV8N65161; Mon, 18 Dec 2000 12:31:08 -0600 (CST) (envelope-from nectar@spawn.nectar.com) Date: Mon, 18 Dec 2000 12:31:08 -0600 From: "Jacques A. Vidrine" To: Warner Losh Cc: hackers@FreeBSD.ORG Subject: Re: Why not another style thread? (was Re: cvs commit: src/lib/libc/gen getgrent.c) Message-ID: <20001218123108.A65143@hamlet.nectar.com> References: <20001217170316.A63227@hamlet.nectar.com> <200012172110.eBHLAfU46563@freefall.freebsd.org> <20001217151509.A63051@hamlet.nectar.com> <20001217151735.D54486@holly.calldei.com> <20001217153129.B63080@hamlet.nectar.com> <20001217153656.F54486@holly.calldei.com> <20001217155648.C63080@hamlet.nectar.com> <20001217160442.H54486@holly.calldei.com> <20001217170316.A63227@hamlet.nectar.com> <200012180501.WAA87838@harmony.village.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200012180501.WAA87838@harmony.village.org>; from imp@village.org on Sun, Dec 17, 2000 at 10:01:58PM -0700 X-Url: http://www.nectar.com/ Sender: nectar@nectar.com Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, Dec 17, 2000 at 10:01:58PM -0700, Warner Losh wrote: > In message <20001217170316.A63227@hamlet.nectar.com> "Jacques A. Vidrine" writes: > : I hate to give up a line for > : > : if (data) > : free(data); > : > : but neither do I care for ``if (data) free(data);''. I guess if I > : were writing several statements like that in a single file, I would > : consider the macro route (e.g. xfree). > > No offense, but this strikes me as a premature, sub-micro > optimization. None taken. It is however a simple and safe optimization, with no apparent downsides. It has the same attraction as using bit shifts instead of multiplication/division, or saving the value from a function call that will be needed again later, even if you know the function call is trivial. > I doubt that you could measure any difference between > if (foo) free(foo); > and free(foo); > > in the real world. This is probably correct for most applications. Nevertheless, I tend to write it that way at times -- maybe because it seems so natural to me to ask `do I need to free this thing?' -- and that gets translated directly to code. -- Jacques Vidrine / n@nectar.com / jvidrine@verio.net / nectar@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message