Bulk port away from foreach
ClosedPublic

Authored by kossebau on Aug 31 2019, 5:56 AM.

Details

Summary

Few are left as they are with code which needs further analysis
and posssibly fixes

Test Plan

Tests still pass, all widgets quickly tested in occurences.

Diff Detail

Repository
R236 KWidgetsAddons
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kossebau created this revision.Aug 31 2019, 5:56 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptAug 31 2019, 5:56 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
kossebau requested review of this revision.Aug 31 2019, 5:56 AM

I think the patch is fine: +1

Please address/comment on fir :) besides that, another review won't hurt, since you simplify the code in 1-2 places, i.e. the changes are slightly more than just the transition to for.

src/fonthelpers.cpp
97–101

Optionally, you could even write:

static const auto genericNames = {
      QLatin1String("..."), ...
};

This initializer list will then even not require any memory allocation. You don't have.contains() later, though... You'd need to simply use std::find() semantics.

src/kfontsizeaction.cpp
93

Imho here qAsConst(actions()) would be nicer to avoid this->.

src/kviewstateserializer.h
134

I think fir does not compile, does it?

PS: could you do the same for kate.git ? :-D

Thanks for review @dhaumann :) Well, if you like I can give KTextEditor a try, motivated there with my KDevelop hat on :) Let's see when I am sleepless at the computer next time ;)

src/fonthelpers.cpp
97–101

Yes, it was the contains() which was my motivation here to stay with QStringList.

src/kfontsizeaction.cpp
93

Will test is this works, but IIRC actions() returned a normal left-side value thingie, which qAsConst does not want to take.

src/kviewstateserializer.h
134

That was... left as exercise for the person copying the code from the docs ;) Alright, not. Well spotted.

cfeck added inline comments.Sep 1 2019, 1:58 AM
autotests/kacceleratormanagertest.cpp
35

Please use KF5 coding style: Type *var instead of Type* var (also for & references),

kossebau updated this revision to Diff 65089.Sep 1 2019, 6:36 AM
  • align * & & with var name, not type, by current KF coding style
  • fix "fir" for "for"
kossebau added inline comments.Sep 1 2019, 6:50 AM
src/kfontsizeaction.cpp
93

Yes, qAsConst(actions()) does not work, as actions() is a r-value type, which qAsConst does not take (move overload of qAsConst explicitly deleted), following std::as_const here, to not run into dangling pointers.

dhaumann accepted this revision.Sep 1 2019, 8:08 AM

I think this patch is good to go in.

This revision is now accepted and ready to land.Sep 1 2019, 8:08 AM

Thanks. In any case, would wait for after 5.62 tagging/branching, as by experience there still might be one or the other regression slipped in with porting from foreach, so having some weeks of testing from more people running git master makes me feel better, before this gets rolled to the masses :)

btw, already started to do the same to ktexteditor, so in some days you kate devs shall enjoy the review of a similar patch...

This revision was automatically updated to reflect the committed changes.