Use const& in inner loop functions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mixxx |
Fix Released
|
Undecided
|
Owen Williams |
Bug Description
I noticed in soundmanager.cpp that two inner functions use copies rather than references:
QHash<AudioOutput, const CSAMPLE*> requestBuffer(
void pushBuffer(
Note that a copy of the QList is made on every call.
changing these to const references appears to have a nice impact on performance:
Before: Debug [Main]: Stat("SoundDevi
After:
Debug [Main]: Stat("SoundDevi
patch included
Related branches
Changed in mixxx: | |
assignee: | nobody → Owen Williams (ywwg) |
status: | New → In Progress |
Changed in mixxx: | |
status: | Fix Committed → Fix Released |
Huh - assuming this is not just noise that's a nice win. Qt has a feature called implicit sharing which prevents copying the QList. Instead, it keeps a reference count and the copy constructor shares data across all the QLists until one of them is modified at which point it transparently copies the list right before the modification. So unless Qt is mistakenly thinking we're modifying the list and detaching it, I think this doesn't actually copy the elements of the list.
What this does save on is incrementing the reference count and creating a new QList wrapper on the stack. If the measurements aren't noise then this could warrant a quick scan through the engine code to get rid of other uses of implicit sharing.
Patch looks good for 1.11.0 to me -- logic-wise it's a no-op.