Change-Id: I7b4da26bace15c2b632c2dbfe56cc2799bbfdb02
Reviewed-on: https://go-review.googlesource.com/c/go/+/450058
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
"fmt"
"go/format"
"log"
+ "math/bits"
"os"
"path"
"regexp"
// countRegs returns the number of set bits in the register mask.
func countRegs(r regMask) int {
- n := 0
- for r != 0 {
- n += int(r & 1)
- r >>= 1
- }
- return n
+ return bits.OnesCount64(uint64(r))
}
// for sorting a pair of integers by key