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.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2024-01-30 10:11:30 +01:00
parent e1054a8bcd
commit f3663c0ec9
+5 -12
View 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";
}