From d1f73304eb133ca8fd632d849825635bb67862b9 Mon Sep 17 00:00:00 2001 From: Damien Lespiau Date: Wed, 13 Jul 2011 15:03:13 +0100 Subject: [PATCH] tracker: Fix the map look up A few commits ago, an attempt to speed the map look up was done. Unfortunatly, it was missing the case where you actually hit the speed up (once the map is the first element of the array, you never return it). So, make sure that if i is 0, you return the first element of array, while still doing the array reordering is i > 0. --- tracker.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tracker.c b/tracker.c index d7e89ba7..dfdbec59 100644 --- a/tracker.c +++ b/tracker.c @@ -417,15 +417,18 @@ process_locate_map (process_t *process, gulong addr) { map_t *map = &g_array_index (maps, map_t, i); - if (addr >= map->start && addr < map->end && i > 0) + if (addr >= map->start && addr < map->end) { - map_t tmp = *map; + if (i > 0) + { + map_t tmp = *map; - memmove (&(g_array_index (maps, map_t, 1)), - &(g_array_index (maps, map_t, 0)), - i * sizeof (map_t)); + memmove (&(g_array_index (maps, map_t, 1)), + &(g_array_index (maps, map_t, 0)), + i * sizeof (map_t)); - g_array_index (maps, map_t, 0) = tmp; + g_array_index (maps, map_t, 0) = tmp; + } return &g_array_index (maps, map_t, 0); }