]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
path-util: make path_equal() an inline wrapper around path_compare()
authorLennart Poettering <lennart@poettering.net>
Thu, 17 Jun 2021 09:04:31 +0000 (11:04 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 18 Jun 2021 04:46:43 +0000 (13:46 +0900)
The two are completely identical, only the return code is inverted.
let's hence make it easy for the compiler to make it the same function
call even in lowest optimization modes.

src/basic/path-util.c
src/basic/path-util.h

index eb547e7467280b7ae05c1eaf73e8180d324aa28e..e5afb5f5f5e0de1fd258783e672b9b44fe294d40 100644 (file)
@@ -514,10 +514,6 @@ int path_compare(const char *a, const char *b) {
         }
 }
 
-bool path_equal(const char *a, const char *b) {
-        return path_compare(a, b) == 0;
-}
-
 bool path_equal_or_files_same(const char *a, const char *b, int flags) {
         return path_equal(a, b) || files_same(a, b, flags) > 0;
 }
index c6d4668794bfd8235b508da18507a0614534fb49..26e7362d1f5865bb0aa5c596a524e40f7813bf33 100644 (file)
@@ -62,7 +62,11 @@ static inline char* path_startswith(const char *path, const char *prefix) {
         return path_startswith_full(path, prefix, true);
 }
 int path_compare(const char *a, const char *b) _pure_;
-bool path_equal(const char *a, const char *b) _pure_;
+
+static inline bool path_equal(const char *a, const char *b) {
+        return path_compare(a, b) == 0;
+}
+
 bool path_equal_or_files_same(const char *a, const char *b, int flags);
 /* Compares only the last portion of the input paths, ie: the filenames */
 bool path_equal_filename(const char *a, const char *b);