From 81cc31eaa95165d4238f563a1dfe688740f35d90 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Wed, 1 Mar 2017 14:50:34 +0000 Subject: [PATCH] Revert "x/tools/container/intsets: remove unused function" This reverts commit 79902b439b3ef4c163ff5e96ac1f282f31c8a131. Reason for revert: build broken on some platforms. Change-Id: I5ceddc305580ff97f47ae27da831f99e96dab424 Reviewed-on: https://go-review.googlesource.com/37539 Reviewed-by: David R. Jenni Reviewed-by: Alan Donovan --- container/intsets/util.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/container/intsets/util.go b/container/intsets/util.go index 6710278170..dd1db86b1c 100644 --- a/container/intsets/util.go +++ b/container/intsets/util.go @@ -4,6 +4,16 @@ package intsets +// From Hacker's Delight, fig 5.2. +func popcountHD(x uint32) int { + x -= (x >> 1) & 0x55555555 + x = (x & 0x33333333) + ((x >> 2) & 0x33333333) + x = (x + (x >> 4)) & 0x0f0f0f0f + x = x + (x >> 8) + x = x + (x >> 16) + return int(x & 0x0000003f) +} + var a [1 << 8]byte func init() {