GNU bug report logs - #22689
25.1.50; implement logcount

Previous Next

Package: emacs;

Reported by: Mark Oteiza <mvoteiza <at> udel.edu>

Date: Mon, 15 Feb 2016 23:20:01 UTC

Severity: wishlist

Found in version 25.1.50

Done: Mark Oteiza <mvoteiza <at> udel.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Mark Oteiza <mvoteiza <at> udel.edu>
To: Benjamin Riefenstahl <b.riefenstahl <at> turtle-trading.net>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 22689 <at> debbugs.gnu.org
Subject: bug#22689: [PATCH] Add logcount
Date: Sat, 30 Sep 2017 12:59:04 -0400
On 30/09/17 at 06:50pm, Benjamin Riefenstahl wrote:
> Hi Mark,
> 
> Just a drive-by note:
> 
> Mark Oteiza writes:
> > +    {
> > +      unsigned int count;
> > +      for (count = 0; v; count++)
> > +        {
> > +          v &= v - 1;
> > +        }
> > +      XSETINT (res, v);
> > +    }
> 
> Isn't this a fancy way of just saying "XSETINT (res, 0)"?  The variable
> "count" is incremented but never used, so without it the loop
> degenerates to
> 
>       while (v)
>         {
>           v &= v - 1;
>         }
> 
> I other words, this just loops until "v == 0".
> 
> Maybe that assignment should be "XSETINT (res, count)"?  That would
> actually use the variable "count".

I think you're right, thank you.




This bug report was last modified 7 years and 291 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.