From 2fd277d0af2ed15098e2a92cca9e60f3c60d7c2e Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 4 Apr 2020 12:52:40 +0100 Subject: Fix templateness of EntryResolver name wasn't templatable --- netfs/ice/entryResolver.h | 7 +------ netfs/ice/typeConverter.cpp | 2 +- netfs/ice/typeConverter.h | 8 +++++--- netfs/lib/entCache.cpp | 16 +++++++--------- netfs/lib/entCache.h | 2 +- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/netfs/ice/entryResolver.h b/netfs/ice/entryResolver.h index b5efbc3..cbdc789 100644 --- a/netfs/ice/entryResolver.h +++ b/netfs/ice/entryResolver.h @@ -1,16 +1,11 @@ #ifndef NETFS_ENTRYRESOLVER_H #define NETFS_ENTRYRESOLVER_H -#include -#include - -template +template class EntryResolver { public: virtual ~EntryResolver() = default; - using name_t = std::string; - virtual void getID(const name_t &, id_t *) const = 0; virtual void getName(const id_t &, name_t *) const = 0; }; diff --git a/netfs/ice/typeConverter.cpp b/netfs/ice/typeConverter.cpp index 0e3ce7f..8e75326 100644 --- a/netfs/ice/typeConverter.cpp +++ b/netfs/ice/typeConverter.cpp @@ -1,7 +1,7 @@ #include "typeConverter.h" #include -EntryTypeConverter::EntryTypeConverter(const EntryResolver & u, const EntryResolver & g) : +EntryTypeConverter::EntryTypeConverter(const UserLookup & u, const GroupLookup & g) : userLookup(u), groupLookup(g) { diff --git a/netfs/ice/typeConverter.h b/netfs/ice/typeConverter.h index b8d6fcd..fedd204 100644 --- a/netfs/ice/typeConverter.h +++ b/netfs/ice/typeConverter.h @@ -16,15 +16,17 @@ class DLL_PUBLIC TypeConverter { class DLL_PUBLIC EntryTypeConverter : public TypeConverter { public: - EntryTypeConverter(const EntryResolver &, const EntryResolver &); + using UserLookup = EntryResolver; + using GroupLookup = EntryResolver; + EntryTypeConverter(const UserLookup &, const GroupLookup &); // Attributes struct stat convert(const NetFS::Attr &) const; NetFS::Attr convert(const struct stat &) const; protected: - const EntryResolver & userLookup; - const EntryResolver & groupLookup; + const UserLookup & userLookup; + const GroupLookup & groupLookup; }; #endif diff --git a/netfs/lib/entCache.cpp b/netfs/lib/entCache.cpp index 9b78dff..d62f4bf 100644 --- a/netfs/lib/entCache.cpp +++ b/netfs/lib/entCache.cpp @@ -54,18 +54,16 @@ template typename EntCache::entry_ptr EntCache::getEntry(const key_t & key) const { - typename EntCache::entry_ptr ent; if (fillTime + 60 > time(nullptr)) { - ent = getEntryNoFill(key); - } - if (!ent) { - fillCache(); - ent = getEntryNoFill(key); + if (auto ent = getEntryNoFill(key)) { + return ent; + } } - if (!ent) { - throw NetFS::SystemError(EPERM); + fillCache(); + if (auto ent = getEntryNoFill(key)) { + return ent; } - return ent; + throw NetFS::SystemError(EPERM); } template diff --git a/netfs/lib/entCache.h b/netfs/lib/entCache.h index 73cd36d..9facdb3 100644 --- a/netfs/lib/entCache.h +++ b/netfs/lib/entCache.h @@ -26,7 +26,7 @@ class Group { }; template -class EntCache : public EntryResolver { +class EntCache : public EntryResolver { public: EntCache(); ~EntCache() override; -- cgit v1.2.3