Move construction of ExpectedSignal where it belongs
ClosedPublic

Authored by dkurz on Oct 31 2018, 8:55 PM.

Details

Summary

Deduplicate ExpectedSignal creation code by moving it where it
belongs, into proper constructors.

Diff Detail

Repository
R165 Akonadi
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dkurz created this revision.Oct 31 2018, 8:55 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptOct 31 2018, 8:55 PM
Restricted Application added a subscriber: kde-pim. · View Herald Transcript
dkurz requested review of this revision.Oct 31 2018, 8:55 PM
dvratil requested changes to this revision.Nov 1 2018, 1:19 PM
dvratil added a subscriber: dvratil.
dvratil added inline comments.
autotests/libs/entitytreemodeltest.cpp
158

You may even be able to get rid of the type name, as that can be deduced from the initializer list type, or not?

554–557

const

autotests/libs/modelspy.h
46

The move here is kinda pointless: Qt classes are implicitly shared, so copying them means only copying a pointer. And if you make the arguments const &, calling the ctor would be a no-copy and initialization of the member variable would be a copy. Your approach requires a copy to call the ctor and then move for initialization - so copy vs copy+move: const & wins here :)

And while this may sound contradictory to what I replied to your email regarding performance compromises when refactoring, the std::move does not IMO improve code readability or quality (compared to just passing non-POD args as const & ) in this case.

autotests/libs/tagmodeltest.cpp
174

const

219–221

const

267

const

327

const

This revision now requires changes to proceed.Nov 1 2018, 1:19 PM
dkurz updated this revision to Diff 44634.Nov 1 2018, 2:07 PM

Added seven consts

Got rid of explicit type names for the construction of the elements of a QList<ExpectedSignal>

dkurz marked 6 inline comments as done.Nov 1 2018, 2:09 PM

I also fixed the initialization order of ExpectedSignal's members.

dkurz updated this revision to Diff 44635.Nov 1 2018, 2:15 PM

Pass by cref instead of values in ctors

dkurz marked an inline comment as done.Nov 1 2018, 2:18 PM
dkurz added inline comments.
autotests/libs/modelspy.h
46

Fully agreed.

dvratil accepted this revision.Nov 1 2018, 2:21 PM

Looking good. Thanks for your work so far!

This revision is now accepted and ready to land.Nov 1 2018, 2:21 PM
This revision was automatically updated to reflect the committed changes.
dkurz marked an inline comment as done.