From 558fa30aefc2882390dfec63b62cc7d32471de7e Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 26 Jun 2022 11:46:16 -0700 Subject: [PATCH] gvplugin_install: use 'strview_t' to simplify second type string comparison loop --- lib/gvc/gvplugin.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/gvc/gvplugin.c b/lib/gvc/gvplugin.c index af7e0485d..c53975a23 100644 --- a/lib/gvc/gvplugin.c +++ b/lib/gvc/gvplugin.c @@ -98,16 +98,10 @@ bool gvplugin_install(GVC_t *gvc, api_t api, const char *typestr, int quality, /* keep quality sorted within type and insert new duplicates ahead of old */ while (*pnext) { - const char *next_typestr = (*pnext)->typestr; - - // find the end of the next plugin - const char *next_end = strchr(next_typestr, ':'); - if (next_end == NULL) - next_end = next_typestr + strlen(next_typestr); - size_t next_length = next_end - next_typestr; + // find the next plugin + const strview_t next_type = strview((*pnext)->typestr, ':'); - size_t limit = next_length < type.size ? next_length : type.size; - if (strncmp(typestr, next_typestr, limit) != 0 || type.size != next_length) + if (!strview_eq(type, next_type)) break; if (quality >= (*pnext)->quality) break; -- 2.40.0