summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-09-22 17:47:21 +0000
committerDavid Robillard <d@drobilla.net>2008-09-22 17:47:21 +0000
commit9aad7b5727377a65b75c8c8c0afa4a5f3e483eed (patch)
tree202e3fbb96f5703fbdba755e53fb7aa8c5f40f9c /libs
parent2d5163d09911e51a44fb33a1ff813d80440f9b4d (diff)
Speed up MIDI import (and non-cached cases of ControlList::eval) by a factor of roughly eleventy billion.
git-svn-id: svn://localhost/ardour2/branches/3.0@3790 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/evoral/src/ControlList.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp
index b84586ab73..2ff5959afc 100644
--- a/libs/evoral/src/ControlList.cpp
+++ b/libs/evoral/src/ControlList.cpp
@@ -636,6 +636,8 @@ ControlList::truncate_end (double last_coordinate)
beyond the new last coordinate.
*/
+ // FIXME: SLOW! (size() == O(n))
+
uint32_t sz = _events.size();
while (i != _events.rend() && sz > 2) {
@@ -775,7 +777,10 @@ ControlList::unlocked_eval (double x) const
double lval, uval;
double fraction;
- npoints = _events.size();
+ const_iterator length_check_iter = _events.begin();
+ for (npoints = 0; npoints < 4; ++npoints, ++length_check_iter)
+ if (length_check_iter == _events.end())
+ break;
switch (npoints) {
case 0:
@@ -1022,9 +1027,10 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double end, d
{
//cerr << "earliest_event(" << start << ", " << end << ", " << x << ", " << y << ", " << inclusive << endl;
- if (_events.size() == 0)
+ const_iterator length_check_iter = _events.begin();
+ if (_events.empty()) // 0 events
return false;
- else if (_events.size() == 1)
+ else if (_events.end() == ++length_check_iter) // 1 event
return rt_safe_earliest_event_discrete_unlocked(start, end, x, y, inclusive);
// Hack to avoid infinitely repeating the same event