D8098: Strip down and re-write the baloo tags KIO slave

Anthony Fieroni noreply at phabricator.kde.org
Thu Nov 23 08:48:29 UTC 2017


anthonyfieroni added inline comments.

INLINE COMMENTS

> kio_tags.cpp:363
> +
> +        if (result.decodedUrl.contains(QStringLiteral("?//")) || chopLastSection) {
> +            result.tag = result.tag.section(QDir::separator(), 0, -2);

Better reverse conditions

  if (chopLastSection ||...)

You don't need expensive call like contains

> kio_tags.cpp:380-381
>  
> -    QString tag;
> -    QString fileUrl;
> +            if (tag.startsWith(result.tag, Qt::CaseInsensitive)) {
> +                validTag = true;
> +            }

You can use boolean conditions rather than if statements, example

  validTag = validTag || tag.startWith(...)

Why?

1. if validTag is true startWith will not called
2. It's on one line (less and beauty code)

> kio_tags.h:101
> +        QUrl localUrl;
> +        KFileMetaData::UserMetaData metaData = KFileMetaData::UserMetaData(QString());
> +        Query query;

metaData(QString{})

> kio_tags.h:106
>  
> -    QString decodeFileUrl(const QString& urlString);
> -    QString encodeFileUrl(const QString& url);
> +    ParseResult parseUrl(const QUrl& url, bool chopLastSection = false, bool lazyValidation = false);
> +    QStringList m_unassignedTags;

Use enum rather than boolean trap

REPOSITORY
  R293 Baloo

REVISION DETAIL
  https://phabricator.kde.org/D8098

To: smithjd, #frameworks, vhanda, #dolphin, ngraham, dfaure
Cc: anthonyfieroni, dfaure, nicolasfella, ngraham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20171123/83dbf0b7/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list