From owner-freebsd-hackers Wed Nov 12 04:22:04 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id EAA29946 for hackers-outgoing; Wed, 12 Nov 1997 04:22:04 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from dfw-ix12.ix.netcom.com (dfw-ix12.ix.netcom.com [206.214.98.12]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id EAA29940 for ; Wed, 12 Nov 1997 04:21:59 -0800 (PST) (envelope-from wghhicks@ix.netcom.com) Received: (from smap@localhost) by dfw-ix12.ix.netcom.com (8.8.4/8.8.4) id GAA25187 for ; Wed, 12 Nov 1997 06:21:26 -0600 (CST) Received: from atl-ga11-19.ix.netcom.com(199.183.210.179) by dfw-ix12.ix.netcom.com via smap (V1.3) id rma025174; Wed Nov 12 06:21:24 1997 Message-ID: <34699F38.330982A9@ix.netcom.com> Date: Wed, 12 Nov 1997 07:21:12 -0500 From: Jerry Hicks Reply-To: jerry_hicks@bigfoot.com Organization: TerraEarth X-Mailer: Mozilla 4.03b8 [en] (X11; I; FreeBSD 2.2.5-STABLE i386) MIME-Version: 1.0 To: hackers@FreeBSD.ORG Subject: Re: A stylistic question... References: <199711120858.JAA06510@labinfo.iet.unipi.it> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Luigi Rizzo wrote: > > I have always wondered about this: most if not all programs, and some > pieces of the kernel as well (e.g. userconfig.c) > have a menu/usage function which is written like this: > > usage() > { > printf( "bla bla bla...\n" ); > printf( "bla bla bla...\n" ); > printf( "bla bla bla...\n" ); > ... > printf( "bla bla bla...\n" ); > } > > instead of what in my opinion would be much better: > > usage() > { > printf( "%s", "bla bla bla...\n" > "bla bla bla...\n" > ... > "bla bla bla...\n"); > } > > yes the code savings are modest (5-10 bytes/call ? but in the kernel > or boot blocks they still matter...) but at runtime the second > approach is faster since the format string must be parsed only once > and it is the shortest possible. > > Any reason not to use the second method ? > > Cheers > Luigi > -----------------------------+-------------------------------------- > Luigi Rizzo | Dip. di Ingegneria dell'Informazione > email: luigi@iet.unipi.it | Universita' di Pisa > tel: +39-50-568533 | via Diotisalvi 2, 56126 PISA (Italy) > fax: +39-50-568522 | http://www.iet.unipi.it/~luigi/ > _____________________________|______________________________________ Actually, the second form probably lends itself to internationalization better. J. Hicks jerry_hicks@bigfoot.com