From 76212435e8a600cd54c658df74c19379a2593b26 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Tue, 8 Oct 2024 18:04:34 +0100 Subject: [PATCH] libkmod: use strbuf_pushchars() where possible Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/174 Signed-off-by: Lucas De Marchi --- libkmod/libkmod-index.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/libkmod/libkmod-index.c b/libkmod/libkmod-index.c index e1808622..4280be8d 100644 --- a/libkmod/libkmod-index.c +++ b/libkmod/libkmod-index.c @@ -494,15 +494,10 @@ static void index_searchwild__allvalues(struct index_node_f *node, static void index_searchwild__all(struct index_node_f *node, int j, struct strbuf *buf, const char *subkey, struct index_value **out) { - size_t pushed = 0; + size_t pushed; int ch; - while (node->prefix[j]) { - ch = node->prefix[j]; - - pushed += strbuf_pushchar(buf, ch); - j++; - } + pushed = strbuf_pushchars(buf, &node->prefix[j]); for (ch = node->first; ch <= node->last; ch++) { struct index_node_f *child = index_readchild(node, ch); @@ -985,15 +980,10 @@ static void index_mm_searchwild_allvalues(struct index_mm_node *node, static void index_mm_searchwild_all(struct index_mm_node *node, int j, struct strbuf *buf, const char *subkey, struct index_value **out) { - size_t pushed = 0; + size_t pushed; int ch; - while (node->prefix[j]) { - ch = node->prefix[j]; - - pushed += strbuf_pushchar(buf, ch); - j++; - } + pushed = strbuf_pushchars(buf, &node->prefix[j]); for (ch = node->first; ch <= node->last; ch++) { struct index_mm_node *child = index_mm_readchild(node, ch); -- 2.47.3