git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3] mru: Replace mru.[ch] with list.h implementation

From
René Scharfe <l.s.r@web.de>
Date
Jan 21, 2018, 04:38 UTC
Message-ID
<75c9bdc5-1c81-1e03-e865-5e74014bd590@web.de>
In-Reply-To
<CAOCi2DGKkLnY_=-7pMr9VyP7TVsj0b8w-msdNn9ZtXKK8g7u9g@mail.gmail.com>
Am 20.01.2018 um 23:24 schrieb Gargi Sharma:
Show 27 quoted lines
> On Sat, Jan 20, 2018 at 1:02 AM, Eric Wong <e@80x24.org> wrote:
>> Gargi Sharma <gs051095@gmail.com> wrote:
>>> --- a/list.h
>>> +++ b/list.h
>>> @@ -93,6 +93,13 @@ static inline void list_move(struct list_head *elem, struct list_head *head)
>>>        list_add(elem, head);
>>>   }
>>>
>>> +/* Move to the front of the list. */
>>> +static inline void list_move_to_front(struct list_head *elem, struct list_head *head)
>>> +{
>>> +     list_del(elem);
>>> +     list_add(elem, head);
>>> +}
>>> +
>>
>> Since we already have list_move and it does the same thing,
>> I don't think we need a new function, here.
>>
>> Hackers coming from other projects (glibc/urcu/Linux kernel)
>> might appreciate having fewer differences from what they're used
>> to.
> 
> I think the idea behind this function was that it is already being used in two
> places in the code and might be used in other places in the future. I agree
> with your stance, but a list_move_to_front is pretty self explanatory and not
> too different, so it should be alright.

Not sure I understand the point about the function being already used as an argument for adding it, but if there is already one which has the exact sane behavior (list_move() in this case) then that should be used instead of adding a duplicate.

René
Previous: Gargi SharmaNext: Gargi Sharma
Message 6 of 7 in “mru: Replace mru.[ch] with list.h implementation”
  1. mru: Replace mru.[ch] with list.h implementationGargi Sharma, Jan 19, 2018
  2. Eric SunshineJan 20, 2018
  3. Gargi SharmaJan 20, 2018
  4. Eric WongJan 20, 2018
  5. Gargi SharmaJan 20, 2018
  6. René ScharfeJan 21, 2018
  7. Gargi SharmaJan 21, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.