From 1a27c323dd21341875d62c5b13a878859d094318 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Jun 2021 11:04:31 +0200 Subject: [PATCH] path-util: make path_equal() an inline wrapper around path_compare() 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 | 4 ---- src/basic/path-util.h | 6 +++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/basic/path-util.c b/src/basic/path-util.c index eb547e74672..e5afb5f5f5e 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -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; } diff --git a/src/basic/path-util.h b/src/basic/path-util.h index c6d4668794b..26e7362d1f5 100644 --- a/src/basic/path-util.h +++ b/src/basic/path-util.h @@ -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); -- 2.47.3