From eec916ebc4f8823bf3f1bd2c434b7e16861b9bfb Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 26 Jun 2022 12:10:34 -0700 Subject: [PATCH] gvplugin_load: use a 'strview_t' for 'reqpkg' This string is always terminated by `'\0'`, not `':'`, so there is little advantage in using a `strview_t` over a `const char*`. But upcoming changes will refactor the surrounding code to use `strview_t`, so it will be more readable to use `strview_t` consistently here. --- lib/gvc/gvplugin.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/gvc/gvplugin.c b/lib/gvc/gvplugin.c index c53975a23..c26beadc4 100644 --- a/lib/gvc/gvplugin.c +++ b/lib/gvc/gvplugin.c @@ -272,14 +272,14 @@ gvplugin_available_t *gvplugin_load(GVC_t * gvc, api_t api, const char *str) const char *reqdep_end = NULL; size_t reqdep_len = 0; - const char *reqpkg = NULL; + strview_t reqpkg = {NULL}; if (reqtyp_end != NULL) { reqdep = reqtyp_end + strlen(":"); reqdep_end = strchr(reqdep, ':'); if (reqdep_end != NULL) { reqdep_len = (size_t)(reqdep_end - reqdep); - reqpkg = reqdep_end + strlen(":"); + reqpkg = strview(reqdep_end + strlen(":"), '\0'); } else { reqdep_len = strlen(reqdep); } @@ -301,7 +301,7 @@ gvplugin_available_t *gvplugin_load(GVC_t * gvc, api_t api, const char *str) continue; /* dependencies not empty, but mismatched */ } } - if (!reqpkg || strcmp(reqpkg, pnext->package->name) == 0) { + if (!reqpkg.data || strview_str_eq(reqpkg, pnext->package->name)) { // found with no packagename constraints, or with required matching packagename if (dep && apidep != api) /* load dependency if needed, continue if can't find */ -- 2.40.0