bruns added inline comments.

INLINE COMMENTS

> apol wrote in kinotify.cpp:371
> 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.

Have you read the summary?

> it removes the duplicated QFile::decode() calls from the object code.

Your code is expanded in all places again, and even adds more code (the check).

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

Reply via email to