qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC v2 07/38] queue: add QTAILQ_REMOVE_SEVERAL


From: Alex Bennée
Subject: Re: [Qemu-devel] [RFC v2 07/38] queue: add QTAILQ_REMOVE_SEVERAL
Date: Mon, 25 Feb 2019 16:22:52 +0000
User-agent: mu4e 1.1.0; emacs 26.1

Emilio G. Cota <address@hidden> writes:

> This is faster than removing elements one by one.
>
> Will gain a user soon.
>
> Signed-off-by: Emilio G. Cota <address@hidden>
> ---
>  include/qemu/queue.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/include/qemu/queue.h b/include/qemu/queue.h
> index ac418efc43..0283c2dd7d 100644
> --- a/include/qemu/queue.h
> +++ b/include/qemu/queue.h
> @@ -419,6 +419,16 @@ struct {                                                 
>                \
>          (elm)->field.tqe_prev = NULL;                                   \
>  } while (/*CONSTCOND*/0)
>
> +/* remove @left, @right and all elements in between from @head */
> +#define QTAILQ_REMOVE_SEVERAL(head, left, right, field) do {    \
> +        if (((right)->field.tqe_next) != NULL)                  \
> +            (right)->field.tqe_next->field.tqe_prev =           \
> +                (left)->field.tqe_prev;                         \
> +        else                                                    \
> +            (head)->tqh_last = (left)->field.tqe_prev;          \
> +        *(left)->field.tqe_prev = (right)->field.tqe_next;      \

This seems wrong, shouldn't it be:

  (left)->field.tqe_prev->field.tqe_next = (right)->field.tqe_next;

Although to be honest every time I read the QUEUE macros I end up with a 
headache...

> +    } while (/*CONSTCOND*/0)
> +
>  #define QTAILQ_FOREACH(var, head, field)                                \
>          for ((var) = ((head)->tqh_first);                               \
>                  (var);                                                  \


--
Alex Bennée



reply via email to

[Prev in Thread] Current Thread [Next in Thread]