[PATCH i-g-t 1/2] lib/igt_drm_fdinfo: Use longest match first

Lucas De Marchi lucas.demarchi at intel.com
Thu Feb 1 00:46:24 UTC 2024


Instead of checking twice the match, just use longest match first.

Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
 lib/igt_drm_fdinfo.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/lib/igt_drm_fdinfo.c b/lib/igt_drm_fdinfo.c
index 222ccbfb1..5c0ccf624 100644
--- a/lib/igt_drm_fdinfo.c
+++ b/lib/igt_drm_fdinfo.c
@@ -239,8 +239,15 @@ __igt_parse_drm_fdinfo(int dir, const char *fd, struct drm_client_fdinfo *info,
 					 strlen("drm-client-id")))) {
 			info->id = atol(v);
 			good++;
-		} else if (!strncmp(l, "drm-engine-", 11) &&
-			   strncmp(l, "drm-engine-capacity-", 20)) {
+		} else if (!strncmp(l, "drm-engine-capacity-", 20)) {
+			idx = parse_engine(l, info,
+					   strlen("drm-engine-capacity-"),
+					   name_map, map_entries, &val);
+			if (idx >= 0) {
+				info->capacity[idx] = val;
+				num_capacity++;
+			}
+		} else if (!strncmp(l, "drm-engine-", 11)) {
 			idx = parse_engine(l, info, strlen("drm-engine-"),
 					   name_map, map_entries, &val);
 			if (idx >= 0) {
@@ -251,14 +258,6 @@ __igt_parse_drm_fdinfo(int dir, const char *fd, struct drm_client_fdinfo *info,
 				if (idx > info->last_engine_index)
 					info->last_engine_index = idx;
 			}
-		} else if (!strncmp(l, "drm-engine-capacity-", 20)) {
-			idx = parse_engine(l, info,
-					   strlen("drm-engine-capacity-"),
-					   name_map, map_entries, &val);
-			if (idx >= 0) {
-				info->capacity[idx] = val;
-				num_capacity++;
-			}
 		} else if (!strncmp(l, "drm-total-", 10)) {
 			idx = parse_region(l, info, strlen("drm-total-"),
 					   region_map, region_entries, &val);
-- 
2.43.0



More information about the igt-dev mailing list