From a6dd998d313e60a1a350d206ca8275aaa83db20a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 28 Feb 2015 23:30:53 +0100 Subject: fs/AllocatedPath: use PathTraitsFS::Relative() Eliminate duplicate code. --- src/fs/AllocatedPath.cxx | 22 ---------------------- src/fs/AllocatedPath.hxx | 4 +++- 2 files changed, 3 insertions(+), 23 deletions(-) (limited to 'src/fs') diff --git a/src/fs/AllocatedPath.cxx b/src/fs/AllocatedPath.cxx index 51a058ffc..087cbf76a 100644 --- a/src/fs/AllocatedPath.cxx +++ b/src/fs/AllocatedPath.cxx @@ -61,28 +61,6 @@ AllocatedPath::ToUTF8() const return ::PathToUTF8(c_str()); } -const char * -AllocatedPath::Relative(const char *other_fs) const -{ - const size_t l = length(); - if (memcmp(data(), other_fs, l) != 0) - return nullptr; - - other_fs += l; - if (*other_fs != 0) { - if (!PathTraitsFS::IsSeparator(*other_fs)) - /* mismatch */ - return nullptr; - - /* skip remaining path separators */ - do { - ++other_fs; - } while (PathTraitsFS::IsSeparator(*other_fs)); - } - - return other_fs; -} - void AllocatedPath::ChopSeparators() { diff --git a/src/fs/AllocatedPath.hxx b/src/fs/AllocatedPath.hxx index 4496981d7..58e12862d 100644 --- a/src/fs/AllocatedPath.hxx +++ b/src/fs/AllocatedPath.hxx @@ -249,7 +249,9 @@ public: * nullptr on mismatch. */ gcc_pure - const char *Relative(const char *other_fs) const; + const char *Relative(const char *other_fs) const { + return PathTraitsFS::Relative(c_str(), other_fs); + } /** * Chop trailing directory separators. -- cgit v1.2.3