CMakeCacheModel: avoid string memory duplication

Authored by dakon on Nov 17 2018, 9:08 AM.



QString::mid() will create a new string, but this code path will never use the
old variable again. So simply modify the original copy instead.

CMakeCacheModel: remove impossible case

Exactly the same case has been checked 2 if's before.

Diff Detail

R32 KDevelop
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
dakon created this revision.Nov 17 2018, 9:08 AM
Restricted Application added a project: KDevelop. · View Herald TranscriptNov 17 2018, 9:08 AM
Restricted Application added a subscriber: kdevelop-devel. · View Herald Transcript
dakon requested review of this revision.Nov 17 2018, 9:08 AM
brauch accepted this revision.Nov 17 2018, 5:13 PM
brauch added a subscriber: brauch.

Looks ok to me, thanks!

This revision is now accepted and ready to land.Nov 17 2018, 5:13 PM
This revision was automatically updated to reflect the committed changes.
mwolff added a subscriber: mwolff.Nov 18 2018, 7:55 PM
mwolff added inline comments.

would be easier to just write

currentComment += line.midRef(2);
dakon added inline comments.Nov 18 2018, 8:09 PM

Since "line" itself goes away after this loop there isn't anything to ref anymore, and I honestly don't know if this will work then. currentComment is a QStringList, no QString.

ah I see, then your code should indeed be better!