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.
This commit is contained in:
Damien Lespiau
2011-07-13 15:03:13 +01:00
committed by Søren Sandmann Pedersen
parent 791fff95c3
commit d1f73304eb

View File

@ -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);
}