Re: [dev] sbase TODO patch

From: Rob <>
Date: Thu, 9 Feb 2012 22:06:08 +0000

On Thu, Feb 09, 2012 at 10:37:51PM +0100, Lukas Fleischer wrote:
> On Thu, Feb 09, 2012 at 04:06:59PM -0500, Galos, David wrote:
> > malloc() in yes(1) is definitely overkill. I've attached a simple
> > version.
> Invoking malloc() once (resulting in O(1) additional time and space) is
> overkill but using printf() in every iteration (which means firing up
> the printf() parser over and over again) isn't? I think you're a tad off
> base, sir...
> There's only two ways to implement this properly:
> * Build the string during program initialization and use puts() (or
> something similar) to print that string over and over again.
> * Call the output routine once for each token in each iteration. If we
> use buffered streams, this shouldn't make much difference. We should
> probably do some quick performance tests to be sure, though.

What's more, that version prints "a\nb\n" for ./yes a b,
instead of "a b\n".
Forgot completely about puts() though.

Received on Thu Feb 09 2012 - 23:06:08 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 09 2012 - 23:12:04 CET