Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jun 2018 00:55:17 +0000 (UTC)
From:      Matt Macy <mmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334748 - head/lib/libpmc
Message-ID:  <201806070055.w570tH71059272@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806070055.w570tH71059272>