-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Effects manifest defaults #10837
Effects manifest defaults #10837
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -99,5 +99,22 @@ const QDomElement EffectPreset::toXml(QDomDocument* doc) const { | |||||||||
return effectElement; | ||||||||||
} | ||||||||||
|
||||||||||
EffectPreset::~EffectPreset() { | ||||||||||
void EffectPreset::updateParametersFrom(const EffectPreset& other) { | ||||||||||
DEBUG_ASSERT(backendType() == other.backendType()); | ||||||||||
|
||||||||||
// technically algorithmically inefficient solution O(n²). May be | ||||||||||
// optimizable by sorting first, gains depend on parameter count | ||||||||||
for (const auto& parameterToCopy : other.m_effectParameterPresets) { | ||||||||||
auto currentParameterIt = | ||||||||||
std::find_if(m_effectParameterPresets.begin(), | ||||||||||
m_effectParameterPresets.end(), | ||||||||||
[&](const auto& ourParameter) { | ||||||||||
return ourParameter.id() == parameterToCopy.id(); | ||||||||||
}); | ||||||||||
if (currentParameterIt == m_effectParameterPresets.end()) { | ||||||||||
continue; | ||||||||||
} | ||||||||||
// overwrite our parameter by taking a copy of the same parameter from `other` | ||||||||||
*currentParameterIt = parameterToCopy; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I just realized, does this create a dangling reference? How do I force a copy here so
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the proposed version is redundant because the copy constructor is already used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking more about it, I'm pretty sure its the copy-assignment operator, so we should be good then. |
||||||||||
} | ||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the best way would be to make m_effectParameterPresets a QHash.
Than the std::find_if becomes a fast:
auto currentParameterIt = m_effectParameterPresets.find(parameterToCopy.id());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify? Do you mean that we change
m_effectParameterPresets
to be a QHash instead of aQList
? That won't work because we need to preserve the ordering ofm_effectParameterPresets
. What would work though is if we just built a temporary QHash on each call. What do you think?