[TagsFileItemAction] Move expensive tag retrieval out of the loop
ClosedPublic

Authored by bruns on Apr 26 2019, 10:35 PM.

Details

Summary

Fetching the tags from the UserMetaData causes two syscalls typically,
repeating it for each known tag is unnecessary work.

Diff Detail

Repository
R824 Baloo Widgets
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
bruns created this revision.Apr 26 2019, 10:35 PM
Restricted Application added a project: Baloo. · View Herald TranscriptApr 26 2019, 10:35 PM
bruns requested review of this revision.Apr 26 2019, 10:35 PM

arc patch fails for me, but the patch looks sane

 INFO  Base commit is not in local repository; trying to fetch.
Created and checked out branch arcpatch-D20856.


    This diff is against commit 021605253fb22071e8fb8646d087d4f7de4a1ab6, but
    the commit is nowhere in the working copy. Try to apply it against the
    current working copy state? (9cda8c72b8244b623680ddb26f5b4e60d636259d)
    [Y/n] y

Checking patch src/tagsfileitemactionplugin/tagsfileitemaction.cpp...
error: while searching for:

    connect(&m_tagsLister, &KCoreDirLister::itemsAdded, this, [this](const QUrl&, const KFileItemList& items) {

        for (const KFileItem &item: items) {
            const QString name = item.name();

            QAction* action = m_menu->addAction(QIcon::fromTheme(QStringLiteral("tag")), name);
            action->setCheckable(true);
            action->setChecked(m_metaData->tags().contains(name));

            connect(action, &QAction::triggered, this, [this, name](bool isChecked) {
                QStringList newTags = m_metaData->tags();

error: patch failed: src/tagsfileitemactionplugin/tagsfileitemaction.cpp:45
Applying patch src/tagsfileitemactionplugin/tagsfileitemaction.cpp with 1 reject...
Rejected hunk #1.

 Patch Failed! 
Usage Exception: Unable to apply patch!
src/tagsfileitemactionplugin/tagsfileitemaction.cpp
48

Missing const

bruns updated this revision to Diff 57127.Apr 28 2019, 11:02 AM

add const

elvisangelaccio accepted this revision.Apr 28 2019, 11:07 AM
This revision is now accepted and ready to land.Apr 28 2019, 11:07 AM
This revision was automatically updated to reflect the committed changes.