emacs-devel
[Top][All Lists]
Advanced

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

Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109864: Fix minor problems found


From: Paul Eggert
Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109864: Fix minor problems found by static checking.
Date: Tue, 04 Sep 2012 01:58:51 -0700
User-agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0

On 09/04/2012 01:31 AM, Jan Djärv wrote:

> Given that Emacs have quite a lot of functions that are more than a
> couple of hundred lines long, it is not typically easy.  For smaller
> functions, it can be, but small functions sometimes becomes big.

No doubt our styles differ, but I don't find it that hard.

For example, on my screen right now I have lib/mktime.c.  It has a
function __mktime_internal that is a couple of hundred lines long.  As
I understand it, you're proposing that almost all of its dozens of
local variables should be decorated with 'const'.  That is, something
like this:

  int min = tp->tm_min;
  int hour = tp->tm_hour;
  int mday = tp->tm_mday;
  int mon = tp->tm_mon;
  int year_requested = tp->tm_year;
  int isdst = tp->tm_isdst;

would be changed to something like this:

  const int min = tp->tm_min;
  const int hour = tp->tm_hour;
  const int mday = tp->tm_mday;
  const int mon = tp->tm_mon;
  const int year_requested = tp->tm_year;
  const int isdst = tp->tm_isdst;

I dunno.  To me those 'const's would take up valuable screen real
estate, and they would slow me down when I read the code, and it's
really not worth the trouble.  If I want to know whether mday is
modified later, I can just search for 'mday'; that's fast.  And in the
typical case where I'm not interested in that particular detail, the
'const's would be wasting my time.




reply via email to

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