Remove foreach in KmPlot in favor of range-based loops
ClosedPublic

Authored by yurchor on Sep 25 2019, 8:09 AM.

Details

Summary

foreach is obsolete

Test Plan
  1. Compile, install, run.
  2. Create some plot (sin(x)), save it, export it, close it, load it.
  3. Use equation editor.

Diff Detail

Repository
R334 KmPlot
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
yurchor created this revision.Sep 25 2019, 8:09 AM
Restricted Application added a project: KDE Edu. · View Herald TranscriptSep 25 2019, 8:09 AM
Restricted Application added a subscriber: kde-edu. · View Herald Transcript
yurchor requested review of this revision.Sep 25 2019, 8:09 AM
aacid added a subscriber: aacid.Sep 26 2019, 9:41 PM

There's some more other lists that maybe are not const, not sure if we care a lot though, but it's always too have "the best code possible"

Up to you if you want to change it or not

kmplot/equationhighlighter.cpp
71–72

mark variables and functions as const?

kmplot/function.cpp
390

what would you think of

const QStringList listSplit = ( (p1 != -1) && (p2 != -1) ) ? m_fstr.mid( p1+1, p2-p1-1 ).split( ',', QString::SkipEmptyParts ) : {};

620

qDeleteAll?

832

qAsConst?

849

qAsConst?

879

qAsConst?

895

qAsConst?

kmplot/functioneditor.cpp
126

qAsConst?

233

qAsConst?

729

qAsConst?

yurchor marked 10 inline comments as done.Sep 27 2019, 6:56 AM

Fixed. Thanks.

yurchor updated this revision to Diff 66938.Sep 27 2019, 6:57 AM

Constify iterators

aacid accepted this revision.Sep 27 2019, 7:19 PM

In general the only problem in porting forach to for( : ) is when the list was modified inside foreach since forach made a "copy-on-write" and for doesn't.

I don't see any such case here so let's hope it's good.

This revision is now accepted and ready to land.Sep 27 2019, 7:19 PM
This revision was automatically updated to reflect the committed changes.