libpmc: simplify lookup by idx
This commit is contained in:
parent
41abd7afa3
commit
1b000b505b
@ -37,6 +37,7 @@
|
||||
#include <string.h>
|
||||
#include <pmc.h>
|
||||
#include <pmclog.h>
|
||||
#include <assert.h>
|
||||
#include <libpmcstat.h>
|
||||
#include "pmu-events/pmu-events.h"
|
||||
|
||||
@ -165,13 +166,11 @@ const char *
|
||||
pmc_pmu_event_get_by_idx(const char *cpuid, int idx)
|
||||
{
|
||||
const struct pmu_events_map *pme;
|
||||
const struct pmu_event *pe;
|
||||
int i;
|
||||
|
||||
if ((pme = pmu_events_map_get(cpuid)) == NULL)
|
||||
return (NULL);
|
||||
for (i = 0, pe = pme->table; (pe->name || pe->desc || pe->event) && i < idx; pe++, i++);
|
||||
return (pe->name);
|
||||
assert(pme->table[idx].name);
|
||||
return (pme->table[idx].name);
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user