]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/pretty-print: use normal else-if cascade
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 14 Dec 2023 09:57:05 +0000 (10:57 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 30 Jan 2024 09:11:30 +0000 (10:11 +0100)
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

index 7dd31a099f5d6f722ef70c539b44a1c5ab790a29..d28c231d58e0dd607ec303c9eaeb5b822375aacb 100644 (file)
@@ -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";
         }