Skip to content

Commit 1ea6232

Browse files
committed
Improve message listener system for 5x higher throughput
1 parent d531a5f commit 1ea6232

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+604
-218
lines changed

Source/Canvas.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Canvas::~Canvas()
193193
saveViewportState();
194194
zoomScale.removeListener(this);
195195
editor->removeModifierKeyListener(this);
196-
pd->unregisterMessageListener(patch.getUncheckedPointer(), this);
196+
pd->unregisterMessageListener(this);
197197
patch.setVisible(false);
198198
}
199199

@@ -2478,7 +2478,7 @@ bool Canvas::panningModifierDown()
24782478
return isPanDragKeysActive || ModifierKeys::getCurrentModifiers().isMiddleButtonDown();
24792479
}
24802480

2481-
void Canvas::receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 8> const& atoms, int numAtoms)
2481+
void Canvas::receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms)
24822482
{
24832483
switch (hash(symbol->s_name)) {
24842484
case hash("sync"):

Source/Canvas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class Canvas : public Component
177177

178178
ObjectParameters& getInspectorParameters();
179179

180-
void receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 8> const& atoms, int numAtoms) override;
180+
void receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override;
181181

182182
void activateCanvasSearchHighlight(Object* obj);
183183
void removeCanvasSearchHighlight();

Source/Connection.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Connection::Connection(Canvas* parent, Iolet* s, Iolet* e, t_outconnect* oc)
9393

9494
Connection::~Connection()
9595
{
96-
cnv->pd->unregisterMessageListener(ptr.getRawUnchecked<void>(), this);
96+
cnv->pd->unregisterMessageListener(this);
9797
cnv->selectedComponents.removeChangeListener(this);
9898

9999
if (outlet) {
@@ -369,14 +369,28 @@ void Connection::popPathState()
369369
updatePath();
370370
}
371371

372+
t_pd* Connection::getTargetObject(t_outconnect* oc)
373+
{
374+
struct _outconnect
375+
{
376+
struct _outconnect *oc_next;
377+
t_pd *oc_to;
378+
t_symbol* oc_path_data;
379+
t_signal* oc_signal;
380+
void* oc_signal_reference;
381+
};
382+
383+
return reinterpret_cast<_outconnect*>(oc)->oc_to;
384+
}
385+
372386
void Connection::setPointer(t_outconnect* newPtr)
373387
{
374388
auto originalPointer = ptr.getRawUnchecked<t_outconnect>();
375389
if (originalPointer != newPtr) {
376390
ptr = pd::WeakReference(newPtr, cnv->pd);
377391

378-
cnv->pd->unregisterMessageListener(originalPointer, this);
379-
cnv->pd->registerMessageListener(newPtr, this);
392+
cnv->pd->unregisterMessageListener(this);
393+
cnv->pd->registerMessageListener(getTargetObject(newPtr), this);
380394
}
381395
}
382396

@@ -569,8 +583,8 @@ StringArray Connection::getMessageFormated()
569583
formatedMessage.add("symbol:");
570584
formatedMessage.add(args[0].toString());
571585
} else if (name == "list") {
572-
if (lastNumArgs >= 8) {
573-
formatedMessage.add("list (7+):");
586+
if (lastNumArgs >= 7) {
587+
formatedMessage.add("list (6+):");
574588
} else {
575589
formatedMessage.add("list (" + String(lastNumArgs) + "):");
576590
}
@@ -581,7 +595,7 @@ StringArray Connection::getMessageFormated()
581595
formatedMessage.add(args[arg].toString());
582596
}
583597
}
584-
if (lastNumArgs >= 8) {
598+
if (lastNumArgs >= 7) {
585599
formatedMessage.add("...");
586600
}
587601
} else {
@@ -1366,7 +1380,7 @@ void ConnectionPathUpdater::timerCallback()
13661380
canvas->patch.endUndoSequence("SetConnectionPaths");
13671381
}
13681382

1369-
void Connection::receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 8> const& atoms, int numAtoms)
1383+
void Connection::receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms)
13701384
{
13711385
if (cnv->shouldShowConnectionActivity()) {
13721386
startTimer(StopAnimation, 1000 / 8.0f);

Source/Connection.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class Connection : public DrawablePath
9797

9898
bool straightLineIntersectsObject(Line<float> toCheck, SmallArray<Object*>& objects);
9999

100-
void receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 8> const& atoms, int numAtoms) override;
100+
void receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override;
101101

102102
bool isSelected() const;
103103

@@ -111,6 +111,8 @@ class Connection : public DrawablePath
111111
Animation };
112112

113113
void timerCallback(int ID) override;
114+
115+
static t_pd* getTargetObject(t_outconnect* oc);
114116

115117
void animate();
116118

@@ -158,7 +160,7 @@ class Connection : public DrawablePath
158160
NVGCachedPath cachedPath;
159161
pd::WeakReference ptr;
160162

161-
StackArray<pd::Atom, 8> lastValue;
163+
StackArray<pd::Atom, 7> lastValue;
162164
int lastNumArgs = 0;
163165
t_symbol* lastSelector = nullptr;
164166

Source/Objects/ArrayObject.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class GraphicalArray : public Component
5757

5858
~GraphicalArray()
5959
{
60-
pd->unregisterMessageListener(arr.getRawUnchecked<void>(), this);
60+
pd->unregisterMessageListener(this);
6161
}
6262

6363
static HeapArray<float> rescale(HeapArray<float> const& v, unsigned const newSize)
@@ -222,7 +222,7 @@ class GraphicalArray : public Component
222222
}
223223
}
224224

225-
void receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 8> const& atoms, int numAtoms) override
225+
void receiveMessage(t_symbol* symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override
226226
{
227227
switch (hash(symbol->s_name)) {
228228
case hash("edit"): {
@@ -712,7 +712,7 @@ struct ArrayPropertiesPanel : public PropertiesPanelProperty
712712

713713
AddArrayButton addButton;
714714
OwnedArray<SmallIconButton> deleteButtons;
715-
SmallArray<Value> nameValues;
715+
HeapArray<Value> nameValues;
716716

717717
std::function<void()> syncCanvas = []() { };
718718

@@ -1316,7 +1316,7 @@ class ArrayObject final : public ObjectBase {
13161316
});
13171317
}
13181318

1319-
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 8> const& atoms, int numAtoms) override
1319+
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override
13201320
{
13211321
switch (symbol) {
13221322
case hash("redraw"): {
@@ -1409,7 +1409,7 @@ class ArrayDefineObject final : public TextBase {
14091409
}
14101410
}
14111411

1412-
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 8> const& atoms, int numAtoms) override
1412+
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override
14131413
{
14141414
}
14151415
};

Source/Objects/BangObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class BangObject final : public ObjectBase
206206
}
207207
}
208208

209-
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 8> const& atoms, int numAtoms) override
209+
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override
210210
{
211211
switch (symbol) {
212212
case hash("float"):

Source/Objects/BicoeffObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ class BicoeffObject final : public ObjectBase {
624624
graph.saveProperties();
625625
}
626626

627-
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 8> const& atoms, int numAtoms) override
627+
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override
628628
{
629629
switch (symbol) {
630630
case hash("allpass"): {

Source/Objects/ButtonObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class ButtonObject final : public ObjectBase {
272272
}
273273
}
274274

275-
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 8> const& atoms, int numAtoms) override
275+
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override
276276
{
277277
switch (symbol) {
278278
case hash("bgcolor"): {

Source/Objects/CanvasObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class CanvasObject final : public ObjectBase {
8080
repaint();
8181
}
8282

83-
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 8> const& atoms, int numAtoms) override
83+
void receiveObjectMessage(hash32 symbol, StackArray<pd::Atom, 7> const& atoms, int numAtoms) override
8484
{
8585
switch (symbol) {
8686
case hash("size"):

0 commit comments

Comments
 (0)