소스 검색

[ALSA] usb-audio: optimize snd_usbmidi_count_bits()

Modules: USB generic driver

Reduce the code size of the snd_usbmidi_count_bits() function by using
simpler operations.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Clemens Ladisch 19 년 전
부모
커밋
62f09c3d32
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      sound/usb/usbmidi.c

+ 3 - 3
sound/usb/usbmidi.c

@@ -871,10 +871,10 @@ static int snd_usbmidi_in_endpoint_create(struct snd_usb_midi* umidi,
 
 static unsigned int snd_usbmidi_count_bits(unsigned int x)
 {
-	unsigned int bits = 0;
+	unsigned int bits;
 
-	for (; x; x >>= 1)
-		bits += x & 1;
+	for (bits = 0; x; ++bits)
+		x &= x - 1;
 	return bits;
 }