[Spice-devel] [PATCH 00/15] Simplify current_add_equal function loop
Frediano Ziglio
fziglio at redhat.com
Tue May 17 14:28:19 UTC 2016
>
> On 05/16/2016 01:40 PM, Frediano Ziglio wrote:
> > These patches should be probably squashed together.
>
> Oh yes, I had a hard time trying to go through all of them, can you
> paste the squashed version somewhere? Or even as a reply to this one?
>
> Thanks, Eduardo.
>
Here you are:
diff --git a/server/display-channel.c b/server/display-channel.c
index 7715b95..daf13fa 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -464,7 +464,6 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
if (is_same_drawable(drawable, other_drawable)) {
DisplayChannelClient *dcc;
- RedDrawablePipeItem *dpi;
RingItem *worker_ring_item, *dpi_ring_item;
other_drawable->refs++;
@@ -472,27 +471,15 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
/* sending the drawable to clients that already received
* (or will receive) other_drawable */
- worker_ring_item = ring_get_head(&RED_CHANNEL(display)->clients);
dpi_ring_item = ring_get_head(&other_drawable->pipes);
/* dpi contains a sublist of dcc's, ordered the same */
- while (worker_ring_item) {
+ RING_FOREACH (worker_ring_item, &RED_CHANNEL(display)->clients) {
dcc = SPICE_CONTAINEROF(worker_ring_item, DisplayChannelClient,
common.base.channel_link);
- dpi = SPICE_CONTAINEROF(dpi_ring_item, RedDrawablePipeItem, base);
- while (worker_ring_item && (!dpi || dcc != dpi->dcc)) {
- dcc_prepend_drawable(dcc, drawable);
- worker_ring_item = ring_next(&RED_CHANNEL(display)->clients,
- worker_ring_item);
- dcc = SPICE_CONTAINEROF(worker_ring_item, DisplayChannelClient,
- common.base.channel_link);
- }
-
- if (dpi_ring_item) {
+ if (dpi_ring_item && dcc == SPICE_CONTAINEROF(dpi_ring_item, RedDrawablePipeItem, base)->dcc) {
dpi_ring_item = ring_next(&other_drawable->pipes, dpi_ring_item);
- }
- if (worker_ring_item) {
- worker_ring_item = ring_next(&RED_CHANNEL(display)->clients,
- worker_ring_item);
+ } else {
+ dcc_prepend_drawable(dcc, drawable);
}
}
/* not sending other_drawable where possible */
Quite hard to understand it's doing the same exact thing.
Frediano
More information about the Spice-devel
mailing list