[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87a8q0eamw.fsf@rasmusvillemoes.dk>
Date: Thu, 26 Nov 2015 22:03:35 +0100
From: Rasmus Villemoes <linux@...musvillemoes.dk>
To: Joe Perches <joe@...ches.com>
Cc: Jiri Kosina <jikos@...nel.org>, linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] HID: debug: improve hid_debug_event()
On Wed, Nov 25 2015, Joe Perches <joe@...ches.com> 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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists