svn commit: r334748 - head/lib/libpmc

Matt Macy mmacy at FreeBSD.org
Thu Jun 7 00:55:18 UTC 2018


Author: mmacy
Date: Thu Jun  7 00:55:17 2018
New Revision: 334748
URL: https://svnweb.freebsd.org/changeset/base/334748

Log:
  libpmc: simplify lookup by idx

Modified:
  head/lib/libpmc/libpmc_pmu_util.c   (contents, props changed)

Modified: head/lib/libpmc/libpmc_pmu_util.c
==============================================================================
--- head/lib/libpmc/libpmc_pmu_util.c	Thu Jun  7 00:54:43 2018	(r334747)
+++ head/lib/libpmc/libpmc_pmu_util.c	Thu Jun  7 00:55:17 2018	(r334748)
@@ -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


More information about the svn-src-all mailing list