[Spice-commits] 16 commits - server/display-channel.c
Frediano Ziglio
fziglio at kemper.freedesktop.org
Wed May 25 14:28:28 UTC 2016
server/display-channel.c | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
New commits:
commit 89e3a85cfed9dc2dac0ba85dbbf1334d2f3c731f
Merge: 091d640 ca5db16
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Wed May 25 15:27:05 2016 +0100
Simplify current_add_equal loop
Acked-by: Eduardo Lima <etrunko at redhat.com>
commit ca5db16cb8451829bdfaf07e2d736fd45b4547d7
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Wed May 25 09:29:44 2016 +0100
dc: use FOREACH_CLIENT macro for loop
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index 1b1bea6..cfa182c 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -467,24 +467,21 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
DisplayChannelClient *dcc;
RingItem *dpi_ring_item;
- GList *link;
+ GList *link, *next;
other_drawable->refs++;
current_remove_drawable(display, other_drawable);
/* sending the drawable to clients that already received
* (or will receive) other_drawable */
- link = RED_CHANNEL(display)->clients;
dpi_ring_item = ring_get_head(&other_drawable->pipes);
/* dpi contains a sublist of dcc's, ordered the same */
- while (link) {
- dcc = link->data;
+ FOREACH_CLIENT(display, link, next, dcc) {
if (dpi_ring_item && dcc == SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item)->dcc) {
dpi_ring_item = ring_next(&other_drawable->pipes, dpi_ring_item);
} else {
dcc_prepend_drawable(dcc, drawable);
}
- link = link->next;
}
/* not sending other_drawable where possible */
drawable_remove_from_pipes(other_drawable);
commit 25d4a665192574ec31e7b8ba7a3b14362e8d9889
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 14:02:33 2016 +0100
dc: inline dpi computation
Actually not exactly the same as this fix a bug if base is not the
first element (in this case if dpi_ring_item is NULL dpi is not)
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index a87d40a..1b1bea6 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -466,7 +466,6 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
if (is_same_drawable(drawable, other_drawable)) {
DisplayChannelClient *dcc;
- RedDrawablePipeItem *dpi;
RingItem *dpi_ring_item;
GList *link;
@@ -480,8 +479,7 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
/* dpi contains a sublist of dcc's, ordered the same */
while (link) {
dcc = link->data;
- dpi = SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item);
- if (dpi && dcc == dpi->dcc) {
+ if (dpi_ring_item && dcc == SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item)->dcc) {
dpi_ring_item = ring_next(&other_drawable->pipes, dpi_ring_item);
} else {
dcc_prepend_drawable(dcc, drawable);
commit 0c91530b07d2991293360ba72c391913049c7236
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 14:00:29 2016 +0100
dc: join the two loop
They tested the same condition, no break in inside loop (which would
exit all loops)
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index f3251f3..a87d40a 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -479,16 +479,14 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
dpi_ring_item = ring_get_head(&other_drawable->pipes);
/* dpi contains a sublist of dcc's, ordered the same */
while (link) {
- while (link) {
- dcc = link->data;
- dpi = SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item);
- if (dpi && dcc == dpi->dcc) {
- dpi_ring_item = ring_next(&other_drawable->pipes, dpi_ring_item);
- } else {
- dcc_prepend_drawable(dcc, drawable);
- }
- link = link->next;
+ dcc = link->data;
+ dpi = SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item);
+ if (dpi && dcc == dpi->dcc) {
+ dpi_ring_item = ring_next(&other_drawable->pipes, dpi_ring_item);
+ } else {
+ dcc_prepend_drawable(dcc, drawable);
}
+ link = link->next;
}
/* not sending other_drawable where possible */
drawable_remove_from_pipes(other_drawable);
commit 85d3af793d636d8c4b8f3aeb1815420b80a250d2
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 13:59:08 2016 +0100
dc: reuse code inside loop
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index 10bd2a9..f3251f3 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -484,10 +484,9 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
dpi = SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item);
if (dpi && dcc == dpi->dcc) {
dpi_ring_item = ring_next(&other_drawable->pipes, dpi_ring_item);
- link = link->next;
- continue;
+ } else {
+ dcc_prepend_drawable(dcc, drawable);
}
- dcc_prepend_drawable(dcc, drawable);
link = link->next;
}
}
commit a7b01620155bd58c5273bb7a644b57a0bc56e42e
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 13:58:22 2016 +0100
dc: convert break to continue
Both jump to check worker_ring_item (internal or external loops)
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index 574ba57..10bd2a9 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -485,7 +485,7 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
if (dpi && dcc == dpi->dcc) {
dpi_ring_item = ring_next(&other_drawable->pipes, dpi_ring_item);
link = link->next;
- break;
+ continue;
}
dcc_prepend_drawable(dcc, drawable);
link = link->next;
commit 5fbac6c8cbd7d79971a0c547d93a442fefabcf49
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 13:55:14 2016 +0100
dc: use while again
Convert from for(;;) { if () break; ... } to while
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index ef2b28d..574ba57 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -479,10 +479,7 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
dpi_ring_item = ring_get_head(&other_drawable->pipes);
/* dpi contains a sublist of dcc's, ordered the same */
while (link) {
- for (;;) {
- if (!link) {
- break;
- }
+ while (link) {
dcc = link->data;
dpi = SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item);
if (dpi && dcc == dpi->dcc) {
commit 0010656ea4a201926f59b7d41641461b05752520
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 13:54:01 2016 +0100
dc: if link is NULL jumping outside loop will check variable and exit
The outer loop will exit too.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index 70cbe88..ef2b28d 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -481,7 +481,7 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
while (link) {
for (;;) {
if (!link) {
- goto out_loop;
+ break;
}
dcc = link->data;
dpi = SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item);
@@ -494,7 +494,6 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
link = link->next;
}
}
-out_loop:
/* not sending other_drawable where possible */
drawable_remove_from_pipes(other_drawable);
commit 9a85e3cf343dc4bc059380a1c5a975f26ef63200
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 13:49:44 2016 +0100
dc: if dpi is not NULL even dpi_ring_item is not NULL
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index 8fbd36e..70cbe88 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -486,9 +486,7 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
dcc = link->data;
dpi = SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item);
if (dpi && dcc == dpi->dcc) {
- if (dpi_ring_item) {
- dpi_ring_item = ring_next(&other_drawable->pipes, dpi_ring_item);
- }
+ dpi_ring_item = ring_next(&other_drawable->pipes, dpi_ring_item);
link = link->next;
break;
}
commit 643bf445c59adf475d99d523ea3b677cf4ae7ecc
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 13:46:50 2016 +0100
dc: dpi is always a value computed from dpi_ring_item
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index 512eafa..8fbd36e 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -479,12 +479,12 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
dpi_ring_item = ring_get_head(&other_drawable->pipes);
/* dpi contains a sublist of dcc's, ordered the same */
while (link) {
- dpi = SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item);
for (;;) {
if (!link) {
goto out_loop;
}
dcc = link->data;
+ dpi = SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item);
if (dpi && dcc == dpi->dcc) {
if (dpi_ring_item) {
dpi_ring_item = ring_next(&other_drawable->pipes, dpi_ring_item);
commit dec4b7eca5d0a8764a439b2919ac3610b1f0b0a3
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 13:44:33 2016 +0100
dc: move code inside if
these lines are only executed then the condition are satisfied
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index 6242e48..512eafa 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -486,16 +486,15 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
}
dcc = link->data;
if (dpi && dcc == dpi->dcc) {
+ if (dpi_ring_item) {
+ dpi_ring_item = ring_next(&other_drawable->pipes, dpi_ring_item);
+ }
+ link = link->next;
break;
}
dcc_prepend_drawable(dcc, drawable);
link = link->next;
}
-
- if (dpi_ring_item) {
- dpi_ring_item = ring_next(&other_drawable->pipes, dpi_ring_item);
- }
- link = link->next;
}
out_loop:
/* not sending other_drawable where possible */
commit 7447a9e66c6ef15ce8d3435aaeb240430e6f3247
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 13:41:41 2016 +0100
dc: dcc used is always a value from current link
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index da295c2..6242e48 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -479,19 +479,17 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
dpi_ring_item = ring_get_head(&other_drawable->pipes);
/* dpi contains a sublist of dcc's, ordered the same */
while (link) {
- dcc = link->data;
dpi = SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item);
for (;;) {
if (!link) {
goto out_loop;
}
+ dcc = link->data;
if (dpi && dcc == dpi->dcc) {
break;
}
dcc_prepend_drawable(dcc, drawable);
link = link->next;
- if (link)
- dcc = link->data;
}
if (dpi_ring_item) {
commit a3ad49b326d4b2df330e0b3f46c7876b9f8fd504
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 13:39:52 2016 +0100
dc: link is never null here
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index 437bf8d..da295c2 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -497,9 +497,7 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
if (dpi_ring_item) {
dpi_ring_item = ring_next(&other_drawable->pipes, dpi_ring_item);
}
- if (link) {
- link = link->next;
- }
+ link = link->next;
}
out_loop:
/* not sending other_drawable where possible */
commit 1d39275c3dd03a96842486e4117ee3e376ba1f5a
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 13:38:33 2016 +0100
dc: the link condition make this case terminate loop
dpi_ring_item is changed but ignored
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index e544be9..437bf8d 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -483,7 +483,7 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
dpi = SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item);
for (;;) {
if (!link) {
- break;
+ goto out_loop;
}
if (dpi && dcc == dpi->dcc) {
break;
@@ -501,6 +501,7 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
link = link->next;
}
}
+out_loop:
/* not sending other_drawable where possible */
drawable_remove_from_pipes(other_drawable);
commit a5a9b38f461495a7997ecfd13a49dce0e3924040
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 13:35:42 2016 +0100
dc: split if
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index 72ce145..e544be9 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -482,7 +482,10 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
dcc = link->data;
dpi = SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item);
for (;;) {
- if (!link || (dpi && dcc == dpi->dcc)) {
+ if (!link) {
+ break;
+ }
+ if (dpi && dcc == dpi->dcc) {
break;
}
dcc_prepend_drawable(dcc, drawable);
commit 2d4e1e5e0add5a33b3744d7d149a1e1dc4aa4513
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Sat May 14 13:34:50 2016 +0100
dc: convert to infinite loop
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/display-channel.c b/server/display-channel.c
index 13be947..72ce145 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -481,7 +481,10 @@ static int current_add_equal(DisplayChannel *display, DrawItem *item, TreeItem *
while (link) {
dcc = link->data;
dpi = SPICE_UPCAST(RedDrawablePipeItem, dpi_ring_item);
- while (link && (!dpi || dcc != dpi->dcc)) {
+ for (;;) {
+ if (!link || (dpi && dcc == dpi->dcc)) {
+ break;
+ }
dcc_prepend_drawable(dcc, drawable);
link = link->next;
if (link)
More information about the Spice-commits
mailing list