[Spice-devel] [PATCH 1/2] Change GList in GQueue

Frediano Ziglio fziglio at redhat.com
Wed Sep 14 10:04:53 UTC 2016


> 
> Hey,
> 
> On Mon, Sep 12, 2016 at 04:32:02PM +0100, Frediano Ziglio wrote:
> > This patch is intended to be merged into "RedChannelClient: store pipe
> > items in a GList".
> > 
> > GQueue improve GList for pipe usage as tail inserting/removal/access
> > are O(1) instead of O(n).
> > Also getting the number of items is O(1) instead of O(n).
> > 
> > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> > ---
> >  server/dcc-send.c                   | 12 ++++----
> >  server/dcc.c                        |  2 +-
> >  server/display-channel.c            |  5 +---
> >  server/red-channel-client-private.h |  2 +-
> >  server/red-channel-client.c         | 58
> >  +++++++++++++++++--------------------
> >  server/red-channel-client.h         |  2 +-
> >  6 files changed, 36 insertions(+), 45 deletions(-)
> > 
> > diff --git a/server/display-channel.c b/server/display-channel.c
> > index bd2907f..de25161 100644
> > --- a/server/display-channel.c
> > +++ b/server/display-channel.c
> > @@ -331,10 +331,7 @@ static void drawable_remove_from_pipes(Drawable
> > *drawable)
> >  
> >          dpi = SPICE_UPCAST(RedDrawablePipeItem, item);
> >          rcc = RED_CHANNEL_CLIENT(dpi->dcc);
> > -        if (red_channel_client_pipe_item_is_linked(rcc,
> > &dpi->dpi_pipe_item)) {
> > -            red_channel_client_pipe_remove_and_release(rcc,
> > -
> > &dpi->dpi_pipe_item);
> > -        }
> > +        red_channel_client_pipe_remove_and_release(rcc,
> > &dpi->dpi_pipe_item);
> 
> I'd keep the red_channel_client_pipe_item_is_linked() here, this
> probably belongs to a follow-up patch?
> 

It's just encapsulated in red_channel_client_pipe_remove_and_release
instead of forcing (with no documentation) to do it manually.

> >      }
> >  }
> >  
> > diff --git a/server/red-channel-client.c b/server/red-channel-client.c
> > index 9f678d7..89ab679 100644
> > --- a/server/red-channel-client.c
> > +++ b/server/red-channel-client.c
> > @@ -1626,8 +1619,9 @@ gboolean
> > red_channel_client_no_item_being_sent(RedChannelClient *rcc)
> >  void red_channel_client_pipe_remove_and_release(RedChannelClient *rcc,
> >                                                  RedPipeItem *item)
> >  {
> > -    red_channel_client_pipe_remove(rcc, item);
> > -    red_pipe_item_unref(item);
> > +    if (red_channel_client_pipe_remove(rcc, item)) {
> > +        red_pipe_item_unref(item);
> > +    }
> 
> Is this changing behaviour compared to what was done before?

Same encapsulation change.

> 
> Christophe
> 

Frediano


More information about the Spice-devel mailing list