Removing the update variable and quit earlier if the memory region has no coalesced range. This prepares for the next patch.
Fixes: 3ac7d43a6fbb5d4a3 Signed-off-by: Peter Xu <[email protected]> --- memory.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/memory.c b/memory.c index 360e0cfa67..2f7a67086a 100644 --- a/memory.c +++ b/memory.c @@ -2283,7 +2283,10 @@ void memory_region_add_coalescing(MemoryRegion *mr, void memory_region_clear_coalescing(MemoryRegion *mr) { CoalescedMemoryRange *cmr; - bool updated = false; + + if (QTAILQ_EMPTY(&mr->coalesced)) { + return; + } qemu_flush_coalesced_mmio_buffer(); mr->flush_coalesced_mmio = false; @@ -2292,12 +2295,9 @@ void memory_region_clear_coalescing(MemoryRegion *mr) cmr = QTAILQ_FIRST(&mr->coalesced); QTAILQ_REMOVE(&mr->coalesced, cmr, link); g_free(cmr); - updated = true; } - if (updated) { - memory_region_update_coalesced_range(mr); - } + memory_region_update_coalesced_range(mr); } void memory_region_set_flush_coalesced(MemoryRegion *mr) -- 2.21.0
