From bf04226d6a662af4d66e127a832ac6c69ea75cb7 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Tue, 14 May 2024 22:10:00 +0900 Subject: [PATCH] processor_labels: Remove a needless existence check for insert operation Insert implies that adding new key-value pairs of labels. However, we did put the existence check for the keys of labels. This shouldn't be effective for such operation. Signed-off-by: Hiroshi Hatake --- plugins/processor_labels/labels.c | 33 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/plugins/processor_labels/labels.c b/plugins/processor_labels/labels.c index 62e5323fd43..ee34e639f25 100644 --- a/plugins/processor_labels/labels.c +++ b/plugins/processor_labels/labels.c @@ -1524,26 +1524,27 @@ static int insert_labels(struct cmt *metrics_context, pair->key); if (result == FLB_TRUE) { - result = metrics_context_insert_dynamic_label(metrics_context, - pair->key, - pair->val); + continue; + } - if (result == FLB_FALSE) { - return FLB_FALSE; - } + result = metrics_context_insert_dynamic_label(metrics_context, + pair->key, + pair->val); + + if (result == FLB_FALSE) { + return FLB_FALSE; } - else { - result = metrics_context_contains_static_label(metrics_context, - pair->key); - if (result == FLB_FALSE) { - result = metrics_context_insert_static_label(metrics_context, - pair->key, - pair->val); + result = metrics_context_contains_static_label(metrics_context, + pair->key); - if (result == FLB_FALSE) { - return FLB_FALSE; - } + if (result == FLB_TRUE) { + result = metrics_context_insert_static_label(metrics_context, + pair->key, + pair->val); + + if (result == FLB_FALSE) { + return FLB_FALSE; } } }