diff --git a/xybrid/data/graph.cpp b/xybrid/data/graph.cpp index 674c83d..b767cd5 100644 --- a/xybrid/data/graph.cpp +++ b/xybrid/data/graph.cpp @@ -44,7 +44,7 @@ void Graph::saveData(QCborMap& m) const { QCborArray c; int idx = 0; - for (auto ch : children) { + for (auto& ch : children) { if (!ch->plugin) continue; indices[ch.get()] = idx++; c << ch->toCbor(); @@ -58,14 +58,14 @@ void Graph::saveData(QCborMap& m) const { // array { oIdx, dataType, pIdx, iIdx, dataType, pIdx } QCborArray cn; - for (auto ch : children) { + for (auto& ch : children) { if (!ch->plugin) continue; // already skipped over int idx = indices[ch.get()]; - for (auto dt : ch->outputs) { - for (auto op : dt.second) { + for (auto& dt : ch->outputs) { + for (auto& op : dt.second) { auto o = op.second; o->cleanConnections(); // let's just do some groundskeeping here - for (auto iw : o->connections) { + for (auto& iw : o->connections) { auto i = iw.lock(); QCborArray c; c << idx; diff --git a/xybrid/data/node.cpp b/xybrid/data/node.cpp index 8f5f0db..494eb04 100644 --- a/xybrid/data/node.cpp +++ b/xybrid/data/node.cpp @@ -48,7 +48,7 @@ bool Port::connect(std::shared_ptr p) { // actual processing is always done on the input port, since that's where any limits are if (type == Output) return p->type == Input && p->connect(shared_from_this()); if (!canConnectTo(p->dataType())) return false; // can't hook up to an incompatible data type - for (auto c : connections) if (c.lock() == p) return true; // I guess report success if already connected? + for (auto& c : connections) if (c.lock() == p) return true; // I guess report success if already connected? if (singleInput() && connections.size() > 0) return false; // reject multiple connections on single-input ports if (auto o = owner.lock(), po = p->owner.lock(); !o || !po || po->dependsOn(o)) return false; // no dependency loops! // actually hook up @@ -118,7 +118,7 @@ QCborMap Node::multiToCbor(std::vector>& v) { { /* nodes */ } { QCborArray nm; int idx = 0; - for (auto n : v) { + for (auto& n : v) { if (n->isVolatile()) continue; // skip things with volatile locality (i/o ports etc.) indices[n.get()] = idx++; nm << n->toCbor(); @@ -129,21 +129,21 @@ QCborMap Node::multiToCbor(std::vector>& v) { // exported samples if (auto v = Sample::finishExport(); !v.empty()) { QCborMap smp; - for (auto s : v) smp[QCborValue(s->uuid)] = s->toCbor(); + for (auto& s : v) smp[QCborValue(s->uuid)] = s->toCbor(); m[qs("samples")] = smp; } { /* connections */ } { QCborArray cm; - for (auto n : v) { + for (auto& n : v) { if (n->isVolatile()) continue; // already skipped int idx = indices[n.get()]; - for (auto dt : n->outputs) { - for (auto op : dt.second) { + for (auto& dt : n->outputs) { + for (auto& op : dt.second) { auto o = op.second; o->cleanConnections(); // let's just do some groundskeeping here - for (auto iw : o->connections) { + for (auto& iw : o->connections) { auto i = iw.lock(); if (auto in = indices.find(i->owner.lock().get()); in != indices.end()) { // only connections within the collection QCborArray c; @@ -166,7 +166,7 @@ QCborMap Node::multiToCbor(std::vector>& v) { { /* center */ } { int count = 0; QPoint center; - for (auto n : v) { + for (auto& n : v) { if (n->isVolatile()) continue; center += QPoint(n->x, n->y); count++; @@ -227,7 +227,7 @@ std::vector> Node::multiFromCbor(const QCborMap& m, std::s if (!cp.isNull()) { // offset and such QPoint off = cp - center; - for (auto n : v) { + for (auto& n : v) { n->x += off.x(); n->y += off.y(); } @@ -305,7 +305,7 @@ void Node::collapsePorts(Port::Type t, Port::DataType dt) { if (mdt == m.end()) return; // nothing there auto& mm = mdt->second; uint8_t maxIdx = 0; - for (auto p : mm) maxIdx = std::max(maxIdx, p.first); + for (auto& p : mm) maxIdx = std::max(maxIdx, p.first); uint8_t firstUnused = 255; for (uint8_t i = 0; i <= maxIdx; i++) { if (auto pi = mm.find(i); pi != mm.end()) { @@ -347,7 +347,7 @@ bool Node::try_process(bool checkDependencies) { if (checkDependencies) { // check if dependencies are done auto checkInput = Util::yCombinator([tick_this](auto checkInput, std::shared_ptr p) -> bool { - for (auto c : p->connections) { // check each connection; if node valid... + for (auto& c : p->connections) { // check each connection; if node valid... if (auto cp = c.lock(); cp) { if (auto n = cp->owner.lock(); n) { if (n->tick_last != tick_this) return false; // if node itself not yet processed, check failed @@ -363,7 +363,7 @@ bool Node::try_process(bool checkDependencies) { return true; }); - for (auto t : inputs) for (auto p : t.second) if (!checkInput(p.second)) return false; + for (auto& t : inputs) for (auto& p : t.second) if (!checkInput(p.second)) return false; /*for (auto& t : inputs) { for (auto& p : t.second) { diff --git a/xybrid/data/porttypes.cpp b/xybrid/data/porttypes.cpp index 26526a7..74329fa 100644 --- a/xybrid/data/porttypes.cpp +++ b/xybrid/data/porttypes.cpp @@ -30,7 +30,7 @@ void AudioPort::pull() { bufR = &bufL[ts]; // for some reason just adding the size wonks out memset(bufL, 0, s*2); // clear buffers - for (auto c : connections) { // mix + for (auto& c : connections) { // mix if (auto p = std::static_pointer_cast(c.lock()); p && p->dataType() == Audio) { p->pull(); for (size_t i = 0; i < ts; i++) { @@ -62,7 +62,7 @@ void CommandPort::pull() { size = 0; if (type == Input) { - for (auto c : connections) { + for (auto& c : connections) { if (auto p = std::static_pointer_cast(c.lock()); p && p->dataType() == Command) { p->pull(); data = p->data; // just repoint to input's buffer diff --git a/xybrid/ui/gadgets/sampleselectorgadget.cpp b/xybrid/ui/gadgets/sampleselectorgadget.cpp index 622339e..2a0ae11 100644 --- a/xybrid/ui/gadgets/sampleselectorgadget.cpp +++ b/xybrid/ui/gadgets/sampleselectorgadget.cpp @@ -138,7 +138,7 @@ void SampleSelectorGadget::mousePressEvent(QGraphicsSceneMouseEvent* e) { m->addAction("(no sample)", this, [this] { setSample(nullptr); }); m->addSeparator(); DirectoryNode root; - for (auto s : qAsConst(project->samples)) root.placeData(s->name, s->uuid); + for (auto& s : qAsConst(project->samples)) root.placeData(s->name, s->uuid); root.sortTree(); buildSubmenu(&root, m); diff --git a/xybrid/ui/gadgets/selectorgadget.cpp b/xybrid/ui/gadgets/selectorgadget.cpp index cfcb880..fbf75c0 100644 --- a/xybrid/ui/gadgets/selectorgadget.cpp +++ b/xybrid/ui/gadgets/selectorgadget.cpp @@ -57,7 +57,7 @@ void SelectorGadget::mousePressEvent(QGraphicsSceneMouseEvent* e) { std::vector v = fGetList ? fGetList() : std::vector(); if (v.empty()) m->addAction("(no entries)")->setDisabled(true); else { - for (auto e : v) { + for (auto& e : v) { if (_entry.first == e.first) { m->addAction(e.second)->setDisabled(true); } else m->addAction(e.second, this, [this, e] { diff --git a/xybrid/ui/patchboard/patchboardscene.cpp b/xybrid/ui/patchboard/patchboardscene.cpp index 1effa51..e343241 100644 --- a/xybrid/ui/patchboard/patchboardscene.cpp +++ b/xybrid/ui/patchboard/patchboardscene.cpp @@ -115,7 +115,7 @@ PatchboardScene::PatchboardScene(QGraphicsView* parent, const std::shared_ptrdata("xybrid-internal/x-graph-copy")), graph, center); setSelectionArea(QPainterPath()); // deselect all - for (auto n : v) { // and select pasted objects + for (auto& n : v) { // and select pasted objects auto o = new NodeObject(n); addItem(o); o->setSelected(true); @@ -225,7 +225,7 @@ void PatchboardScene::refresh() { // build scene from graph clear(); - for (auto n : graph->children) { + for (auto& n : graph->children) { auto* o = new NodeObject(n); addItem(o); } diff --git a/xybrid/ui/samplelistmodel.cpp b/xybrid/ui/samplelistmodel.cpp index defe9e4..bca0b8f 100644 --- a/xybrid/ui/samplelistmodel.cpp +++ b/xybrid/ui/samplelistmodel.cpp @@ -99,7 +99,7 @@ void SampleListModel::refresh() { root = std::make_shared(); auto* project = window->getProject().get(); if (!project) return; - for (auto s : qAsConst(project->samples)) root->placeData(s->name, s->uuid); + for (auto& s : qAsConst(project->samples)) root->placeData(s->name, s->uuid); root->sortTree(); view->setCurrentIndex(QModelIndex()); @@ -237,7 +237,7 @@ bool SampleListModel::dropMimeData(const QMimeData *data, Qt::DropAction action, QList urls = data->urls(); bool success = false; - for (auto u : urls) { + for (auto& u : urls) { if (!u.isLocalFile()) continue; auto smp = Sample::fromFile(u.toLocalFile()); if (smp) { // valid sample returned