From f3663c0ec9e3a92c9c7256a37e7e8872d8628d8c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 14 Dec 2023 10:57:05 +0100 Subject: [PATCH] shared/pretty-print: use normal else-if cascade This is not a hot path, but it seems silly to evalute subsequent branches, which can never match once one has matched. Also, it makes the code harder to read, because the reader has to first figure out that only one branch can match. --- src/shared/pretty-print.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/shared/pretty-print.c b/src/shared/pretty-print.c index 7dd31a099f5..d28c231d58e 100644 --- a/src/shared/pretty-print.c +++ b/src/shared/pretty-print.c @@ -350,24 +350,17 @@ static int guess_type(const char **name, char ***prefixes, bool *is_collection, if (path_equal(n, "udev/hwdb.d")) ext = ".hwdb"; - - if (path_equal(n, "udev/rules.d")) + else if (path_equal(n, "udev/rules.d")) ext = ".rules"; - - if (path_equal(n, "kernel/install.d")) + else if (path_equal(n, "kernel/install.d")) ext = ".install"; - - if (path_equal(n, "systemd/ntp-units.d")) { + else if (path_equal(n, "systemd/ntp-units.d")) { coll = true; ext = ".list"; - } - - if (path_equal(n, "systemd/relabel-extra.d")) { + } else if (path_equal(n, "systemd/relabel-extra.d")) { coll = run = true; ext = ".relabel"; - } - - if (PATH_IN_SET(n, "systemd/system-preset", "systemd/user-preset")) { + } else if (PATH_IN_SET(n, "systemd/system-preset", "systemd/user-preset")) { coll = true; ext = ".preset"; } -- 2.47.3