Replace single-linked with double-linked lists. It results in more
compact and more efficient code. * grub-core/kern/list.c (grub_list_push): Moved from here ... * include/grub/list.h (grub_list_push): ... to here. Set prev. (grub_list_remove): Moved from here ... * include/grub/list.h (grub_list_remove): ... here. Use and set prev. (grub_prio_list_insert): Set prev. * include/grub/list.h (grub_list): Add prev. All users updated.
This commit is contained in:
parent
48b391e9ab
commit
87edb8940a
27 changed files with 111 additions and 75 deletions
|
@ -21,26 +21,6 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
|
||||
void
|
||||
grub_list_push (grub_list_t *head, grub_list_t item)
|
||||
{
|
||||
item->next = *head;
|
||||
*head = item;
|
||||
}
|
||||
|
||||
void
|
||||
grub_list_remove (grub_list_t *head, grub_list_t item)
|
||||
{
|
||||
grub_list_t *p, q;
|
||||
|
||||
for (p = head, q = *p; q; p = &(q->next), q = q->next)
|
||||
if (q == item)
|
||||
{
|
||||
*p = q->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void *
|
||||
grub_named_list_find (grub_named_list_t head, const char *name)
|
||||
{
|
||||
|
@ -81,6 +61,9 @@ grub_prio_list_insert (grub_prio_list_t *head, grub_prio_list_t nitem)
|
|||
|
||||
*p = nitem;
|
||||
nitem->next = q;
|
||||
if (q)
|
||||
q->prev = &nitem->next;
|
||||
nitem->prev = p;
|
||||
|
||||
if (! inactive)
|
||||
nitem->prio |= GRUB_PRIO_LIST_FLAG_ACTIVE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue