[KRunner] Avoid writing history if addToHistory is idempotent
ClosedPublic

Authored by bruns on Apr 8 2019, 3:19 PM.

Details

Summary

It is not uncommon to run the same command repeatedly. In this case,
the history is actually unchanged - the item is removed from the first
position, and prepended again.

Test Plan

run the same command twice, config file is not rewritten
run a new command, config is updated

Diff Detail

Repository
R120 Plasma Workspace
Branch
arcpatch-D20383
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 10647
Build 10665: arc lint + arc unit
bruns created this revision.Apr 8 2019, 3:19 PM
Restricted Application added a project: Plasma. · View Herald TranscriptApr 8 2019, 3:19 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
bruns requested review of this revision.Apr 8 2019, 3:19 PM
apol added a comment.Apr 9 2019, 1:00 AM

I'm not sure what we win but I'm not against the optimization.

krunner/view.cpp
370

m_history.constFirst() == item

bruns updated this revision to Diff 55793.Apr 9 2019, 2:10 AM

use const

bruns marked an inline comment as done.Apr 9 2019, 2:14 AM
broulik accepted this revision.Apr 9 2019, 7:46 AM
This revision is now accepted and ready to land.Apr 9 2019, 7:46 AM
This revision was automatically updated to reflect the committed changes.