[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/6] exec.c: get nodes_nb_alloc with one MAX calcula
From: |
Wei Yang |
Subject: |
[Qemu-devel] [PATCH 3/6] exec.c: get nodes_nb_alloc with one MAX calculation |
Date: |
Thu, 21 Mar 2019 16:25:52 +0800 |
The purpose of these two MAX here is to get the maximum of these three
variables:
A: map->nodes_nb + nodes
B: map->nodes_nb_alloc
C: alloc_hint
We can write it like MAX(A, B, C). Since the if condition says A > B,
this means MAX(A, B, C) = MAX(A, C).
This patch just simplify the calculation a bit.
Signed-off-by: Wei Yang <address@hidden>
---
exec.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/exec.c b/exec.c
index 8e8b6bb1f9..78bf810ae8 100644
--- a/exec.c
+++ b/exec.c
@@ -226,8 +226,7 @@ static void phys_map_node_reserve(PhysPageMap *map,
unsigned nodes)
{
static unsigned alloc_hint = 16;
if (map->nodes_nb + nodes > map->nodes_nb_alloc) {
- map->nodes_nb_alloc = MAX(map->nodes_nb_alloc, alloc_hint);
- map->nodes_nb_alloc = MAX(map->nodes_nb_alloc, map->nodes_nb + nodes);
+ map->nodes_nb_alloc = MAX(alloc_hint, map->nodes_nb + nodes);
map->nodes = g_renew(Node, map->nodes, map->nodes_nb_alloc);
alloc_hint = map->nodes_nb_alloc;
}
--
2.19.1
- [Qemu-devel] [PATCH 0/6] Refine exec, Wei Yang, 2019/03/21
- [Qemu-devel] [PATCH 1/6] exec.c: replace hwaddr with uint64_t for better understanding, Wei Yang, 2019/03/21
- [Qemu-devel] [PATCH 2/6] exec.c: remove an unnecessary assert on PHYS_MAP_NODE_NIL in phys_map_node_alloc(), Wei Yang, 2019/03/21
- [Qemu-devel] [PATCH 3/6] exec.c: get nodes_nb_alloc with one MAX calculation,
Wei Yang <=
- [Qemu-devel] [PATCH 4/6] exec.c: subpage->sub_section is already initialized to 0, Wei Yang, 2019/03/21
- [Qemu-devel] [PATCH 5/6] exec.c: correct the maximum skip value during compact, Wei Yang, 2019/03/21
- [Qemu-devel] [PATCH 6/6] exec.c: add a check between constants to see whether we could skip, Wei Yang, 2019/03/21