|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63773 Improve BitSet::cardinality() performance
Submitted: 2012-12-14 20:18 UTC Modified: 2017-10-24 08:00 UTC
From: harroyo at hangar18 dot cc Assigned:
Status: Open Package: Bitset (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
28 - 11 = ?
Subscribe to this entry?

 [2012-12-14 20:18 UTC] harroyo at hangar18 dot cc
Current implementation of BitSet::cardinality() counts bits one at a time. This 
can be done a lot better using known fast methods for computing the "hamming 
weight". The easiest way (for Linux) would be to check if the compiler is GCC and 
use the __builtin_popcount() it provides, or use one of the implementations shown 

Probably it would also need to change the type of bitset_val on from unsigned 
char* to unsigned long* (or unsigned long long * etc, so 32/64 bits are handled 
at a time).


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-12-14 20:28 UTC]
-Assigned To: +Assigned To: willfitch
 [2017-10-24 08:00 UTC]
-Status: Assigned +Status: Open -Assigned To: willfitch +Assigned To:
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 06:01:34 2024 UTC