D28325: [Inotify] Call QFile::decode only in a single place
Aleix Pol Gonzalez
noreply at phabricator.kde.org
Fri Mar 27 00:40:53 GMT 2020
apol added inline comments.
INLINE COMMENTS
> kinotify.cpp:365
>
> + // All events which need a decoded path, i.e. everything
> + // but EventMoveFrom | EventQueueOverflow | EventIgnored
Indentation looks off.
> kinotify.cpp:371
> + EventMoveTo | EventOpen | EventUnmount;
> + const QString fname = event->mask & fileEvents ? QFile::decodeName(path) : QString();
> +
This conditional looks off, maybe it would make sense to have an intermediate class to decide when to initialize it?
Something like this:
template <typename T>
class Delayed
{
public:
Delayed(std::function<T()> func) : m_func(func) {}
T operator*() {
if (!m_value) {
m_value = m_func();
}
return *m_value;
}
std::function<T()> m_func;
std::optional<T> m_value;
};
and consuming it as
Delayed<QString> fname([&path]{return QFile::decodeName(path);});
//...
Q_EMIT accessed(*fname);
Then the object itself makes sure it's initialised just once without the risk of forgetting one of the cases.
REPOSITORY
R293 Baloo
REVISION DETAIL
https://phabricator.kde.org/D28325
To: bruns, #baloo, ngraham
Cc: apol, kde-frameworks-devel, hurikhan77, lots0logs, LeGast00n, cblack, fbampaloukas, GB_2, domson, ashaposhnikov, michaelh, astippich, spoorun, ngraham, bruns, abrahams
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20200327/4bb84326/attachment-0001.html>
More information about the Kde-frameworks-devel
mailing list