diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/map.c | 9 | ||||
-rw-r--r-- | tools/perf/util/map_groups.h | 6 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 9 |
3 files changed, 19 insertions, 5 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 49e353eaa337..d0899df77baa 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -572,6 +572,7 @@ void map_groups__init(struct map_groups *mg, struct machine *machine) { maps__init(&mg->maps); mg->machine = machine; + mg->last_search_by_name = NULL; refcount_set(&mg->refcnt, 1); } @@ -580,6 +581,14 @@ void map_groups__insert(struct map_groups *mg, struct map *map) maps__insert(&mg->maps, map); } +void map_groups__remove(struct map_groups *mg, struct map *map) +{ + if (mg->last_search_by_name == map) + mg->last_search_by_name = NULL; + + maps__remove(&mg->maps, map); +} + static void __maps__purge(struct maps *maps) { struct map *pos, *next; diff --git a/tools/perf/util/map_groups.h b/tools/perf/util/map_groups.h index 26fc68bd4f60..f2a3158572eb 100644 --- a/tools/perf/util/map_groups.h +++ b/tools/perf/util/map_groups.h @@ -36,6 +36,7 @@ struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, st struct map_groups { struct maps maps; struct machine *machine; + struct map *last_search_by_name; refcount_t refcnt; #ifdef HAVE_LIBUNWIND_SUPPORT void *addr_space; @@ -70,10 +71,7 @@ size_t map_groups__fprintf(struct map_groups *mg, FILE *fp); void map_groups__insert(struct map_groups *mg, struct map *map); -static inline void map_groups__remove(struct map_groups *mg, struct map *map) -{ - maps__remove(&mg->maps, map); -} +void map_groups__remove(struct map_groups *mg, struct map *map); static inline struct map *map_groups__find(struct map_groups *mg, u64 addr) { diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 0fb9bd8bcf0d..b146d87176e7 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -1767,9 +1767,16 @@ struct map *map_groups__find_by_name(struct map_groups *mg, const char *name) down_read(&maps->lock); + if (mg->last_search_by_name && strcmp(mg->last_search_by_name->dso->short_name, name) == 0) { + map = mg->last_search_by_name; + goto out_unlock; + } + maps__for_each_entry(maps, map) - if (strcmp(map->dso->short_name, name) == 0) + if (strcmp(map->dso->short_name, name) == 0) { + mg->last_search_by_name = map; goto out_unlock; + } map = NULL; |