Iterate over initializer_lists to avoid mem allocs
ClosedPublic

Authored by dhaumann on Dec 5 2017, 5:39 PM.

Details

Summary

I had to add a helper function to avoid messy
STL iterator code everywhere. Not an ideal solution,
but std::contains() simply still does not exist, yet :-)

Test Plan

make test

Diff Detail

Repository
R39 KTextEditor
Branch
AvoidAllocs (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
dhaumann created this revision.Dec 5 2017, 5:39 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptDec 5 2017, 5:39 PM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript
dhaumann requested review of this revision.Dec 5 2017, 5:39 PM
ngraham added a subscriber: ngraham.Dec 5 2017, 5:40 PM
apol accepted this revision.Dec 10 2017, 11:33 PM
This revision is now accepted and ready to land.Dec 10 2017, 11:33 PM

@mwolff I still would like to know from you whether you think this patch makes thinks better: I need additional helper functions etc. just to use the STL to avoid these allocs. Additional helper functions are added complexity, since it's not standard Qt stuff that everyone typically knows out of the box. That's why I am asking :-) So I for one see benefits and drawbacks ;)

much better, but can be somewhat better still.

if people don't know the STL, they should learn it.

src/document/katedocument.cpp
109

you want to return std::distance(list.begin(), it) here

4538–4539

here and below, these could now contain QLatin1String, reducing the size of the binary a bit

4575

add a contains that does this check, also use it below

4669

contains

4754–4755

QLatin1String

4755

contains

4760–4761

QLatin1String

4761

contains

dhaumann updated this revision to Diff 27963.Feb 24 2018, 10:21 PM
  • Add and use contains()
  • Use QLaint1String
dhaumann marked 8 inline comments as done.Feb 25 2018, 11:40 AM

Mark comments as done.

src/document/katedocument.cpp
109

Good catch!