mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-20 01:14:20 +00:00
Performance improvement for Value change notifications.
This commit is contained in:
parent
07e7188eb1
commit
66ecd6bc7c
3 changed files with 92 additions and 60 deletions
|
|
@ -60,11 +60,8 @@ public:
|
|||
void sendPropertyChangeMessage (ValueTree& tree, const Identifier& property)
|
||||
{
|
||||
for (int i = valueTreesWithListeners.size(); --i >= 0;)
|
||||
{
|
||||
ValueTree* const v = valueTreesWithListeners[i];
|
||||
if (v != nullptr)
|
||||
if (ValueTree* const v = valueTreesWithListeners[i])
|
||||
v->listeners.call (&ValueTree::Listener::valueTreePropertyChanged, tree, property);
|
||||
}
|
||||
}
|
||||
|
||||
void sendPropertyChangeMessage (const Identifier& property)
|
||||
|
|
@ -78,11 +75,8 @@ public:
|
|||
void sendChildAddedMessage (ValueTree& tree, ValueTree& child)
|
||||
{
|
||||
for (int i = valueTreesWithListeners.size(); --i >= 0;)
|
||||
{
|
||||
ValueTree* const v = valueTreesWithListeners[i];
|
||||
if (v != nullptr)
|
||||
if (ValueTree* const v = valueTreesWithListeners[i])
|
||||
v->listeners.call (&ValueTree::Listener::valueTreeChildAdded, tree, child);
|
||||
}
|
||||
}
|
||||
|
||||
void sendChildAddedMessage (ValueTree child)
|
||||
|
|
@ -96,11 +90,8 @@ public:
|
|||
void sendChildRemovedMessage (ValueTree& tree, ValueTree& child)
|
||||
{
|
||||
for (int i = valueTreesWithListeners.size(); --i >= 0;)
|
||||
{
|
||||
ValueTree* const v = valueTreesWithListeners[i];
|
||||
if (v != nullptr)
|
||||
if (ValueTree* const v = valueTreesWithListeners[i])
|
||||
v->listeners.call (&ValueTree::Listener::valueTreeChildRemoved, tree, child);
|
||||
}
|
||||
}
|
||||
|
||||
void sendChildRemovedMessage (ValueTree child)
|
||||
|
|
@ -114,11 +105,8 @@ public:
|
|||
void sendChildOrderChangedMessage (ValueTree& tree)
|
||||
{
|
||||
for (int i = valueTreesWithListeners.size(); --i >= 0;)
|
||||
{
|
||||
ValueTree* const v = valueTreesWithListeners[i];
|
||||
if (v != nullptr)
|
||||
if (ValueTree* const v = valueTreesWithListeners[i])
|
||||
v->listeners.call (&ValueTree::Listener::valueTreeChildOrderChanged, tree);
|
||||
}
|
||||
}
|
||||
|
||||
void sendChildOrderChangedMessage()
|
||||
|
|
@ -134,18 +122,12 @@ public:
|
|||
ValueTree tree (this);
|
||||
|
||||
for (int j = children.size(); --j >= 0;)
|
||||
{
|
||||
SharedObject* const child = children.getObjectPointer (j);
|
||||
if (child != nullptr)
|
||||
if (SharedObject* const child = children.getObjectPointer (j))
|
||||
child->sendParentChangeMessage();
|
||||
}
|
||||
|
||||
for (int i = valueTreesWithListeners.size(); --i >= 0;)
|
||||
{
|
||||
ValueTree* const v = valueTreesWithListeners[i];
|
||||
if (v != nullptr)
|
||||
if (ValueTree* const v = valueTreesWithListeners[i])
|
||||
v->listeners.call (&ValueTree::Listener::valueTreeParentChanged, tree);
|
||||
}
|
||||
}
|
||||
|
||||
const var& getProperty (const Identifier& name) const noexcept
|
||||
|
|
@ -167,9 +149,7 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
const var* const existingValue = properties.getVarPointer (name);
|
||||
|
||||
if (existingValue != nullptr)
|
||||
if (const var* const existingValue = properties.getVarPointer (name))
|
||||
{
|
||||
if (*existingValue != newValue)
|
||||
undoManager->perform (new SetPropertyAction (this, name, newValue, *existingValue, false, false));
|
||||
|
|
@ -270,16 +250,10 @@ public:
|
|||
|
||||
bool isAChildOf (const SharedObject* const possibleParent) const noexcept
|
||||
{
|
||||
const SharedObject* p = parent;
|
||||
|
||||
while (p != nullptr)
|
||||
{
|
||||
for (const SharedObject* p = parent; p != nullptr; p = p->parent)
|
||||
if (p == possibleParent)
|
||||
return true;
|
||||
|
||||
p = p->parent;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -611,10 +585,9 @@ public:
|
|||
|
||||
UndoableAction* createCoalescedAction (UndoableAction* nextAction)
|
||||
{
|
||||
MoveChildAction* next = dynamic_cast <MoveChildAction*> (nextAction);
|
||||
|
||||
if (next != nullptr && next->parent == parent && next->startIndex == endIndex)
|
||||
return new MoveChildAction (parent, startIndex, next->endIndex);
|
||||
if (MoveChildAction* next = dynamic_cast <MoveChildAction*> (nextAction))
|
||||
if (next->parent == parent && next->startIndex == endIndex)
|
||||
return new MoveChildAction (parent, startIndex, next->endIndex);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue