[effects/magiclamp] Eliminate unnecessary reallocations
ClosedPublic

Authored by zzag on Jul 14 2018, 9:08 PM.

Details

Summary

The maximum size of newQuads is known in advance, so we can avoid
unnecessary reallocations when adding transformed window quads to
newQuads.

Test Plan

Minimized/unminimized System Settings.

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.Jul 14 2018, 9:08 PM
Restricted Application added a project: KWin. · View Herald TranscriptJul 14 2018, 9:08 PM
Restricted Application added a subscriber: kwin. · View Herald Transcript
zzag requested review of this revision.Jul 14 2018, 9:08 PM
zzag edited the summary of this revision. (Show Details)Jul 14 2018, 9:23 PM
davidedmundson accepted this revision.Jul 14 2018, 10:29 PM
davidedmundson added a subscriber: davidedmundson.

If this is an issue, we could try looking into setting a Q_DECLARE_TYPEINFO on the WindowQuadList.
Right now QList still allocates a second set of memory for complex types separate from the internal void* list that we're pre-allocating here.

This revision is now accepted and ready to land.Jul 14 2018, 10:29 PM
zzag added a comment.Jul 14 2018, 10:40 PM

If this is an issue, we could try looking into setting a Q_DECLARE_TYPEINFO on the WindowQuadList.
Right now QList still allocates a second set of memory for complex types separate from the internal void* list that we're pre-allocating here.

sizeof(WindowQuad) is greater than sizeof(void*), so I'm not sure whether that will help.

In this case, I think the right way would be to use QVector.

This revision was automatically updated to reflect the committed changes.

just saying: I really like these changes. Good work, keep it going!