From owner-freebsd-hackers Wed Nov 12 07:26:45 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id HAA10563 for hackers-outgoing; Wed, 12 Nov 1997 07:26:45 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from labinfo.iet.unipi.it (labinfo.iet.unipi.it [131.114.9.5]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id HAA10540 for ; Wed, 12 Nov 1997 07:26:29 -0800 (PST) (envelope-from luigi@labinfo.iet.unipi.it) Received: from localhost (luigi@localhost) by labinfo.iet.unipi.it (8.6.5/8.6.5) id PAA07129; Wed, 12 Nov 1997 15:16:57 +0100 From: Luigi Rizzo Message-Id: <199711121416.PAA07129@labinfo.iet.unipi.it> Subject: Re: A stylistic question... To: adrian@virginia.edu Date: Wed, 12 Nov 1997 15:16:57 +0100 (MET) Cc: hackers@freebsd.org In-Reply-To: from "Adrian T. Filipi-Martin" at Nov 12, 97 09:16:39 am X-Mailer: ELM [version 2.4 PL23] Content-Type: text Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > > > usage() > > { > > printf( "%s", "bla bla bla...\n" > > "bla bla bla...\n" > > ... > > "bla bla bla...\n"); > > } ... > > Any reason not to use the second method ? > > Not really. It will compile into slightly smaller code and it > will have better runtime performance since there will only one function > call to printf(). > > Why do yo feel that you need the "%s" though? Just make the > "blah..." your format string. The parsing of the format string is pretty > efficient. It reads a char and then switch()'s on it to what to do. the "%s" was added on the fly while composing the message and not knowing the details of format string parsing. After your clarification, then the only possible usefulness is that one must not worry to escape % chars ... a very weak motivation indeed. 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/ _____________________________|______________________________________