From: Zbigniew Jędrzejewski-Szmek Date: Thu, 14 Dec 2023 09:57:05 +0000 (+0100) Subject: shared/pretty-print: use normal else-if cascade X-Git-Tag: v256-rc1~1015^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3663c0ec9e3a92c9c7256a37e7e8872d8628d8c;p=thirdparty%2Fsystemd.git 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. --- 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"; }