Remove Iterator based loops for range based loops
AbandonedPublic

Authored by tcanabrava on Dec 20 2019, 7:15 PM.

Details

Reviewers
ervin
Test Plan

Compiled and run the unittests

Diff Detail

Repository
R237 KConfig
Branch
rangeBasedFor
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 20096
Build 20114: arc lint + arc unit
tcanabrava created this revision.Dec 20 2019, 7:15 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptDec 20 2019, 7:15 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
tcanabrava requested review of this revision.Dec 20 2019, 7:15 PM
ervin requested changes to this revision.Dec 23 2019, 5:18 PM
ervin added a subscriber: ervin.

The patch being large I didn't check each one separately but I suspect this patch misses boat loads of qAsConst. Besides there's at least one case of very flawed logic, it can't be about blindly switching one loop construct for another especially when the iterators are compared inside the loop body.

src/kconfig_compiler/kconfig_compiler.cpp
2119

This logic is very flawed... instead of comparing positions in the list now you're comparing actual values. If two different positions in the list would end up having the same values (for some reason) we'd generate syntactically incorrect code.

This revision now requires changes to proceed.Dec 23 2019, 5:18 PM

The patch being large I didn't check each one separately but I suspect this patch misses boat loads of qAsConst.

Yes, it indeed misses, I'll add the qAsConst. ( I would actually prefer to change the QList to std::vector in the future, no need to add the 'qAsConst' there and it would help readability )

Besides there's at least one case of very flawed logic, it can't be about blindly switching one loop construct for another especially when the iterators are compared inside the loop body.

I didn't blindly change anything, everything I did I tested either by running the unittests or recompilling and testing the settings of applications.

This patch greatly increases the readability of the software. I'll do another round of reviews here adding the qAsConst and trying to find broken logic but I don't believe they are really broken.

tcanabrava added inline comments.Dec 23 2019, 6:22 PM
src/kconfig_compiler/kconfig_compiler.cpp
2119

if two items in the list have the same values the KConfig XML is wrong and the generated code will not compile. I don't see an issue with it.

ervin added a comment.Dec 23 2019, 8:44 PM

I didn't blindly change anything, everything I did I tested either by running the unittests or recompilling and testing the settings of applications.

Sure I know you did this, otherwise I think I'd call you criminal. ;-)

More seriously, I find the test suite of kconfig_compiler unfortunately very slim on error cases (as in XML with crap in them) so that's why we should try to keep in mind "creative" users during reviews. As a corollary, the absence of failing tests doesn't mean the absence of bugs being introduced.
As I'm trying to highlight in my comment below, I think that in that particular case moving away from iterators introduce a regression in behavior and information provided to the user in case of bogus data.

src/kconfig_compiler/kconfig_compiler.cpp
2119

Well, there's a difference between generating malformed code and generating well formed code which doesn't compile for grammar reasons.

Previously it wouldn't compile with a proper error (two parameters with the same name) now it would in most case give a totally unrelated error since the tokenizer would go haywire.

tcanabrava abandoned this revision.Jan 29 2020, 5:26 PM