CMakeCacheModel: avoid string memory duplication
ClosedPublic

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

Details

Summary

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

Repository
R32 KDevelop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
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.
plugins/cmake/settings/cmakecachemodel.cpp
76

would be easier to just write

currentComment += line.midRef(2);
dakon added inline comments.Nov 18 2018, 8:09 PM
plugins/cmake/settings/cmakecachemodel.cpp
76

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!