Re: [PATCH] HID: debug: improve hid_debug_event()
From: Rasmus Villemoes
Date: Thu Nov 26 2015 - 16:03:41 EST
On Wed, Nov 25 2015, Joe Perches <joe@xxxxxxxxxxx> wrote:
>> spin_lock_irqsave(&hdev->debug_list_lock, flags);
>> list_for_each_entry(list, &hdev->debug_list, node) {
>> - for (i = 0; i < strlen(buf); i++)
>> + for (i = 0; buf[i]; i++)
>> list->hid_debug_buf[(list->tail + i) % HID_DEBUG_BUFSIZE] =
>> buf[i];
>> list->tail = (list->tail + i) % HID_DEBUG_BUFSIZE;
>
> trivia:
>
> The code might look nicer if (list->tail + i) % HID_DEBUG_BUFSIZE
> was stored into a temporary.
Maybe.
> Maybe use an if >= BUFSIZE to avoid a %
Nah, that would likely be worse; both a cmov and a conditional jump are
probably more expensive than a simple '& 0x1ff' which the % should compile to
(provided the expression is unsigned).
Rasmus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/