summaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-10-03 00:33:20 +0000
committerDavid Robillard <d@drobilla.net>2011-10-03 00:33:20 +0000
commitaf70d4f1e0927ea3e89b78fdf0de4247a32a39b4 (patch)
tree3515ddb9fbf02fa1c7487f1f185e2bdc6a1d463d /src/server
parentfaa4a675feeba39d81b44340e874e7114755ea86 (diff)
downloadingen-af70d4f1e0927ea3e89b78fdf0de4247a32a39b4.tar.gz
ingen-af70d4f1e0927ea3e89b78fdf0de4247a32a39b4.tar.bz2
ingen-af70d4f1e0927ea3e89b78fdf0de4247a32a39b4.zip
Don't stack allocate buffer array unless it's needed.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3522 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server')
-rw-r--r--src/server/InputPort.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp
index 01a5c414..4a1c9d25 100644
--- a/src/server/InputPort.cpp
+++ b/src/server/InputPort.cpp
@@ -178,12 +178,6 @@ InputPort::pre_process(Context& context)
if (_set_by_user)
return;
- uint32_t max_num_srcs = 0;
- for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c)
- max_num_srcs += (*c)->src_port()->poly();
-
- boost::intrusive_ptr<Buffer> srcs[max_num_srcs];
-
if (_connections.empty()) {
for (uint32_t v = 0; v < _poly; ++v) {
buffer(v)->prepare_read(context);
@@ -194,10 +188,20 @@ InputPort::pre_process(Context& context)
_buffers->at(v)->prepare_read(context);
}
} else {
+ uint32_t max_num_srcs = 0;
+ for (Connections::const_iterator c = _connections.begin();
+ c != _connections.end(); ++c) {
+ max_num_srcs += (*c)->src_port()->poly();
+ }
+
+ boost::intrusive_ptr<Buffer> srcs[max_num_srcs];
+
for (uint32_t v = 0; v < _poly; ++v) {
uint32_t num_srcs = 0;
- for (Connections::iterator c = _connections.begin(); c != _connections.end(); ++c)
+ for (Connections::const_iterator c = _connections.begin();
+ c != _connections.end(); ++c) {
(*c)->get_sources(context, v, srcs, max_num_srcs, num_srcs);
+ }
mix(context, buffer(v).get(), srcs, num_srcs);
buffer(v)->prepare_read(context);