Date: Mon, 18 Dec 2000 12:31:08 -0600 From: "Jacques A. Vidrine" <n@nectar.com> To: Warner Losh <imp@village.org> 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> In-Reply-To: <200012180501.WAA87838@harmony.village.org>; from imp@village.org on Sun, Dec 17, 2000 at 10:01:58PM -0700 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>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001218123108.A65143>