From eefb7cb419c3b096662330a8fec8580fdf565618 Mon Sep 17 00:00:00 2001 From: Rafael RL Date: Mon, 23 Oct 2023 13:01:20 +0200 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit use entry and extend Co-authored-by: John Argérus --- .../databroker/src/grpc/kuksa_val_v1/val.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs b/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs index 7945acf8..7b9e0fe4 100644 --- a/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs +++ b/kuksa_databroker/databroker/src/grpc/kuksa_val_v1/val.rs @@ -414,17 +414,12 @@ impl proto::val_server::Val for broker::DataBroker { .for_each_entry(|entry| { let entry_path = &entry.metadata().path; if regex.is_match(entry_path) { - let id = &entry.metadata().id; - match entries.get(id) { - Some(fields) => { - let joined_set: HashSet<_> = - fields.union(&fields_set).cloned().collect(); - entries.insert(*id, joined_set); - } - None => { - entries.insert(*id, fields_set.clone()); - } - } + entries + .entry(entry.metadata().id) + .and_modify(|existing_fields| { + existing_fields.extend(fields.clone()); + }) + .or_insert(fields.clone()); } }) .await;