Hi
On Sat, Nov 25, 2023 at 11:55 AM lijiejun <a_lijiejun@163.com> wrote:
>
> Reduce unnecessary code execution in function qemu_spice_create_update,
> such as "int blocks = DIV_ROUND_UP(surface_width(ssd->ds), blksize);"
> and "int bpp = surface_bytes_per_pixel(ssd->ds);".
>
> Signed-off-by: lijiejun <a_lijiejun@163.com>
This is a micro-optimization which makes the
qemu_spice_create_update() less complete, mixing caller/callee
responsibilities.
> ---
> ui/spice-display.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/ui/spice-display.c b/ui/spice-display.c
> index 6eb98a5a5c..508e35ed0f 100644
> --- a/ui/spice-display.c
> +++ b/ui/spice-display.c
> @@ -194,10 +194,6 @@ static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
> int bpp = surface_bytes_per_pixel(ssd->ds);
> uint8_t *guest, *mirror;
>
> - if (qemu_spice_rect_is_empty(&ssd->dirty)) {
> - return;
> - };
> -
> dirty_top = g_new(int, blocks);
> for (blk = 0; blk < blocks; blk++) {
> dirty_top[blk] = -1;
> @@ -488,7 +484,9 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
>
> WITH_QEMU_LOCK_GUARD(&ssd->lock) {
> if (QTAILQ_EMPTY(&ssd->updates) && ssd->ds) {
> - qemu_spice_create_update(ssd);
> + if (!qemu_spice_rect_is_empty(&ssd->dirty)) {
> + qemu_spice_create_update(ssd);
> + }
> ssd->notify++;
> }
> }
> --
> 2.25.1
>
>
--
Marc-André Lureau