libpmc: simplify lookup by idx

This commit is contained in:
Matt Macy 2018-06-07 00:55:17 +00:00
parent 41abd7afa3
commit 1b000b505b

View File

@ -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