[PATCH] osmo-pcu[master]: Use built-in bit counter

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Fri Jan 26 17:47:22 UTC 2018


Review at  https://gerrit.osmocom.org/6104

Use built-in bit counter

Use gss' built-in function for counting bits instead of hand-coded
routine.

Change-Id: Iaf470e9a7ee0d003177c4328f93849606ca31521
---
M src/pcu_utils.h
1 file changed, 1 insertion(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/04/6104/1

diff --git a/src/pcu_utils.h b/src/pcu_utils.h
index 767771c..298bb32 100644
--- a/src/pcu_utils.h
+++ b/src/pcu_utils.h
@@ -37,11 +37,7 @@
 template <typename T>
 inline unsigned int pcu_bitcount(T x)
 {
-	unsigned int count = 0;
-	for (count = 0; x; count += 1)
-		x &= x - 1;
-
-	return count;
+	return __builtin_popcount(x);
 }
 
 template <typename T>

-- 
To view, visit https://gerrit.osmocom.org/6104
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf470e9a7ee0d003177c4328f93849606ca31521
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list