From e7ef7f51592e384d4a2ecd2e57af56053fb57e42 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 6 Nov 2015 09:49:39 +0100 Subject: db/update/InotifyQueue: use StringAfterPrefix() --- src/db/update/InotifyQueue.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/db/update/InotifyQueue.cxx b/src/db/update/InotifyQueue.cxx index 392ac4110..3ed7d3d13 100644 --- a/src/db/update/InotifyQueue.cxx +++ b/src/db/update/InotifyQueue.cxx @@ -24,8 +24,6 @@ #include "Log.hxx" #include "util/StringCompare.hxx" -#include - /** * Wait this long after the last change before calling * update_enqueue(). This increases the probability that updates can @@ -55,14 +53,16 @@ InotifyQueue::OnTimeout() } } +gcc_pure static bool path_in(const char *path, const char *possible_parent) { - size_t length = strlen(possible_parent); + if (StringIsEmpty(path)) + return true; - return StringIsEmpty(path) || - (memcmp(possible_parent, path, length) == 0 && - (path[length] == 0 || path[length] == '/')); + auto rest = StringAfterPrefix(path, possible_parent); + return rest != nullptr && + (StringIsEmpty(rest) || rest[0] == '/'); } void -- cgit v1.2.3