[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] FYI: copy-file.c tweak

From: Paul Eggert
Subject: Re: [Bug-gnulib] FYI: copy-file.c tweak
Date: 26 Apr 2003 07:18:20 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Bruno Haible <address@hidden> writes:

> I find the code more readable as it is. 'buf' and 'buf_size' belong
> together.

Fair enough.

>   char buf[4096];
>   const size_t buf_size = sizeof (buf);

While we're on the subject, I find that 'const' to make the code less
readable here.  There's rarely any point declaring a local variable's
type to be 'const': that information is easily deducible from the code
and the extra keyword makes the code harder to read.

> In others we write
>   const size_t buf_size = MIN (MAX (file_size, 4096), 1048576);
>   char *buf = (char *) xmalloc (buf_size);

If you wanted to be truly consistent, you would write 'char * const buf'.
But it would be better to omit 'const' entirely from these examples,
and from the corresponding code in copy-file.c.

> > it avoids the include-file mess.
> "mess"?

Not everyone uses the same include-file rules, and even the people who
understand the rules that you're using don't always follow them
correctly.  So it's better to avoid including a file entirely, all
other things being equal.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]