libpmc: simplify lookup by idx

This commit is contained in:
Matt Macy 2018-06-07 00:55:17 +00:00
parent 41abd7afa3
commit 1b000b505b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334748

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