Use QVector in paintGenericScreen
ClosedPublic

Authored by zzag on Jan 11 2019, 8:01 PM.

Details

Summary

Given that QList<T> will allocate items on the heap when sizeof(T) is
bigger than sizeof(void *), which is the case for Phase2Data, use
QVector instead.

Diff Detail

Repository
R108 KWin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
zzag created this revision.Jan 11 2019, 8:01 PM
Restricted Application added a project: KWin. · View Herald TranscriptJan 11 2019, 8:01 PM
Restricted Application added a subscriber: kwin. · View Herald Transcript
zzag requested review of this revision.Jan 11 2019, 8:01 PM
davidedmundson accepted this revision.Jan 11 2019, 10:45 PM
This revision is now accepted and ready to land.Jan 11 2019, 10:45 PM
This revision was automatically updated to reflect the committed changes.

Actually if we want to improve this I would go for:

  • std::vector
  • reserve
  • emplace_back

That combination would give us zero-copy initialization of the vector and can unfortunately not be achieved with Qt's container classes.

That's due to change in Qt6.
Given that's not too far away, I don't think we should be mixing two different container class types across the core. We're just making work for ourselves. Especially when this is all just premature optimisations.

That's due to change in Qt6.

Oh, I wasn't aware of that. Where do you have that information from? I'd love to read up about it.

Given that's not too far away, I don't think we should be mixing two different container class types across the core. We're just making work for ourselves. Especially when this is all just premature optimisations.

I doubt it's premature. The code is called every frame - small things count.

zzag added a comment.Jan 12 2019, 11:51 AM
  • reserve

Would it be okay?

phase2.reserve(stacking_order.size());

Or should we use some heuristic, e.g. num clients / num desktops?