mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 08:14:58 +01:00
Remove end of SearchCache as it is not used (it's always set to DBL_MAX)
git-svn-id: svn://localhost/ardour2/branches/3.0@7493 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
0bbc9144cc
commit
115083c13d
3 changed files with 44 additions and 57 deletions
|
|
@ -193,12 +193,11 @@ public:
|
||||||
std::pair<ControlList::const_iterator,ControlList::const_iterator> range;
|
std::pair<ControlList::const_iterator,ControlList::const_iterator> range;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Lookup cache for point finding, range contains points between left and right */
|
/** Lookup cache for point finding, range contains points after left */
|
||||||
struct SearchCache {
|
struct SearchCache {
|
||||||
SearchCache() : left(-1), right(-1) {}
|
SearchCache () : left(-1) {}
|
||||||
double left; /* leftmost x coordinate used when finding "range" */
|
double left; /* leftmost x coordinate used when finding "first" */
|
||||||
double right; /* rightmost x coordinate used when finding "range" */
|
ControlList::const_iterator first;
|
||||||
std::pair<ControlList::const_iterator,ControlList::const_iterator> range;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const EventList& events() const { return _events; }
|
const EventList& events() const { return _events; }
|
||||||
|
|
@ -216,9 +215,9 @@ public:
|
||||||
*/
|
*/
|
||||||
double unlocked_eval (double x) const;
|
double unlocked_eval (double x) const;
|
||||||
|
|
||||||
bool rt_safe_earliest_event (double start, double end, double& x, double& y, bool start_inclusive=false) const;
|
bool rt_safe_earliest_event (double start, double& x, double& y, bool start_inclusive=false) const;
|
||||||
bool rt_safe_earliest_event_unlocked (double start, double end, double& x, double& y, bool start_inclusive=false) const;
|
bool rt_safe_earliest_event_unlocked (double start, double& x, double& y, bool start_inclusive=false) const;
|
||||||
bool rt_safe_earliest_event_discrete_unlocked (double start, double end, double& x, double& y, bool inclusive) const;
|
bool rt_safe_earliest_event_discrete_unlocked (double start, double& x, double& y, bool inclusive) const;
|
||||||
|
|
||||||
void create_curve();
|
void create_curve();
|
||||||
void destroy_curve();
|
void destroy_curve();
|
||||||
|
|
@ -247,9 +246,9 @@ protected:
|
||||||
/** Called by unlocked_eval() to handle cases of 3 or more control points. */
|
/** Called by unlocked_eval() to handle cases of 3 or more control points. */
|
||||||
double multipoint_eval (double x) const;
|
double multipoint_eval (double x) const;
|
||||||
|
|
||||||
void build_search_cache_if_necessary(double start, double end) const;
|
void build_search_cache_if_necessary (double start) const;
|
||||||
|
|
||||||
bool rt_safe_earliest_event_linear_unlocked (double start, double end, double& x, double& y, bool inclusive) const;
|
bool rt_safe_earliest_event_linear_unlocked (double start, double& x, double& y, bool inclusive) const;
|
||||||
|
|
||||||
boost::shared_ptr<ControlList> cut_copy_clear (double, double, int op);
|
boost::shared_ptr<ControlList> cut_copy_clear (double, double, int op);
|
||||||
bool erase_range_internal (double start, double end, EventList &);
|
bool erase_range_internal (double start, double end, EventList &);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ ControlList::ControlList (const Parameter& id)
|
||||||
_lookup_cache.left = -1;
|
_lookup_cache.left = -1;
|
||||||
_lookup_cache.range.first = _events.end();
|
_lookup_cache.range.first = _events.end();
|
||||||
_search_cache.left = -1;
|
_search_cache.left = -1;
|
||||||
_search_cache.range.first = _events.end();
|
_search_cache.first = _events.end();
|
||||||
_sort_pending = false;
|
_sort_pending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ ControlList::ControlList (const ControlList& other)
|
||||||
_default_value = other._default_value;
|
_default_value = other._default_value;
|
||||||
_rt_insertion_point = _events.end();
|
_rt_insertion_point = _events.end();
|
||||||
_lookup_cache.range.first = _events.end();
|
_lookup_cache.range.first = _events.end();
|
||||||
_search_cache.range.first = _events.end();
|
_search_cache.first = _events.end();
|
||||||
_sort_pending = false;
|
_sort_pending = false;
|
||||||
|
|
||||||
for (const_iterator i = other._events.begin(); i != other._events.end(); ++i) {
|
for (const_iterator i = other._events.begin(); i != other._events.end(); ++i) {
|
||||||
|
|
@ -89,7 +89,7 @@ ControlList::ControlList (const ControlList& other, double start, double end)
|
||||||
_default_value = other._default_value;
|
_default_value = other._default_value;
|
||||||
_rt_insertion_point = _events.end();
|
_rt_insertion_point = _events.end();
|
||||||
_lookup_cache.range.first = _events.end();
|
_lookup_cache.range.first = _events.end();
|
||||||
_search_cache.range.first = _events.end();
|
_search_cache.first = _events.end();
|
||||||
_sort_pending = false;
|
_sort_pending = false;
|
||||||
|
|
||||||
/* now grab the relevant points, and shift them back if necessary */
|
/* now grab the relevant points, and shift them back if necessary */
|
||||||
|
|
@ -902,29 +902,23 @@ ControlList::multipoint_eval (double x) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ControlList::build_search_cache_if_necessary(double start, double end) const
|
ControlList::build_search_cache_if_necessary (double start) const
|
||||||
{
|
{
|
||||||
/* Only do the range lookup if x is in a different range than last time
|
/* Only do the range lookup if x is in a different range than last time
|
||||||
* this was called (or if the search cache has been marked "dirty" (left<0) */
|
* this was called (or if the search cache has been marked "dirty" (left<0) */
|
||||||
if (!_events.empty() && ((_search_cache.left < 0) ||
|
if (!_events.empty() && ((_search_cache.left < 0) || (_search_cache.left > start))) {
|
||||||
((_search_cache.left > start) ||
|
|
||||||
(_search_cache.right < end)))) {
|
|
||||||
|
|
||||||
const ControlEvent start_point (start, 0);
|
const ControlEvent start_point (start, 0);
|
||||||
const ControlEvent end_point (end, 0);
|
|
||||||
|
|
||||||
//cerr << "REBUILD: (" << _search_cache.left << ".." << _search_cache.right << ") := ("
|
//cerr << "REBUILD: (" << _search_cache.left << ".." << _search_cache.right << ") := ("
|
||||||
// << start << ".." << end << ")" << endl;
|
// << start << ".." << end << ")" << endl;
|
||||||
|
|
||||||
_search_cache.range.first = lower_bound (_events.begin(), _events.end(), &start_point, time_comparator);
|
_search_cache.first = lower_bound (_events.begin(), _events.end(), &start_point, time_comparator);
|
||||||
_search_cache.range.second = upper_bound (_events.begin(), _events.end(), &end_point, time_comparator);
|
|
||||||
|
|
||||||
_search_cache.left = start;
|
_search_cache.left = start;
|
||||||
_search_cache.right = end;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get the earliest event between \a start and \a end, using the current interpolation style.
|
/** Get the earliest event after \a start using the current interpolation style.
|
||||||
*
|
*
|
||||||
* If an event is found, \a x and \a y are set to its coordinates.
|
* If an event is found, \a x and \a y are set to its coordinates.
|
||||||
*
|
*
|
||||||
|
|
@ -932,7 +926,7 @@ ControlList::build_search_cache_if_necessary(double start, double end) const
|
||||||
* \return true if event is found (and \a x and \a y are valid).
|
* \return true if event is found (and \a x and \a y are valid).
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
ControlList::rt_safe_earliest_event(double start, double end, double& x, double& y, bool inclusive) const
|
ControlList::rt_safe_earliest_event (double start, double& x, double& y, bool inclusive) const
|
||||||
{
|
{
|
||||||
// FIXME: It would be nice if this was unnecessary..
|
// FIXME: It would be nice if this was unnecessary..
|
||||||
Glib::Mutex::Lock lm(_lock, Glib::TRY_LOCK);
|
Glib::Mutex::Lock lm(_lock, Glib::TRY_LOCK);
|
||||||
|
|
@ -940,11 +934,11 @@ ControlList::rt_safe_earliest_event(double start, double end, double& x, double&
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rt_safe_earliest_event_unlocked(start, end, x, y, inclusive);
|
return rt_safe_earliest_event_unlocked (start, x, y, inclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Get the earliest event between \a start and \a end, using the current interpolation style.
|
/** Get the earliest event after \a start using the current interpolation style.
|
||||||
*
|
*
|
||||||
* If an event is found, \a x and \a y are set to its coordinates.
|
* If an event is found, \a x and \a y are set to its coordinates.
|
||||||
*
|
*
|
||||||
|
|
@ -952,17 +946,17 @@ ControlList::rt_safe_earliest_event(double start, double end, double& x, double&
|
||||||
* \return true if event is found (and \a x and \a y are valid).
|
* \return true if event is found (and \a x and \a y are valid).
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
ControlList::rt_safe_earliest_event_unlocked(double start, double end, double& x, double& y, bool inclusive) const
|
ControlList::rt_safe_earliest_event_unlocked (double start, double& x, double& y, bool inclusive) const
|
||||||
{
|
{
|
||||||
if (_interpolation == Discrete) {
|
if (_interpolation == Discrete) {
|
||||||
return rt_safe_earliest_event_discrete_unlocked(start, end, x, y, inclusive);
|
return rt_safe_earliest_event_discrete_unlocked(start, x, y, inclusive);
|
||||||
} else {
|
} else {
|
||||||
return rt_safe_earliest_event_linear_unlocked(start, end, x, y, inclusive);
|
return rt_safe_earliest_event_linear_unlocked(start, x, y, inclusive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Get the earliest event between \a start and \a end (Discrete (lack of) interpolation)
|
/** Get the earliest event after \a start without interpolation.
|
||||||
*
|
*
|
||||||
* If an event is found, \a x and \a y are set to its coordinates.
|
* If an event is found, \a x and \a y are set to its coordinates.
|
||||||
*
|
*
|
||||||
|
|
@ -970,19 +964,17 @@ ControlList::rt_safe_earliest_event_unlocked(double start, double end, double& x
|
||||||
* \return true if event is found (and \a x and \a y are valid).
|
* \return true if event is found (and \a x and \a y are valid).
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
ControlList::rt_safe_earliest_event_discrete_unlocked (double start, double end, double& x, double& y, bool inclusive) const
|
ControlList::rt_safe_earliest_event_discrete_unlocked (double start, double& x, double& y, bool inclusive) const
|
||||||
{
|
{
|
||||||
build_search_cache_if_necessary(start, end);
|
build_search_cache_if_necessary (start);
|
||||||
|
|
||||||
const pair<const_iterator,const_iterator>& range = _search_cache.range;
|
if (_search_cache.first != _events.end()) {
|
||||||
|
const ControlEvent* const first = *_search_cache.first;
|
||||||
if (range.first != _events.end()) {
|
|
||||||
const ControlEvent* const first = *range.first;
|
|
||||||
|
|
||||||
const bool past_start = (inclusive ? first->when >= start : first->when > start);
|
const bool past_start = (inclusive ? first->when >= start : first->when > start);
|
||||||
|
|
||||||
/* Earliest points is in range, return it */
|
/* Earliest points is in range, return it */
|
||||||
if (past_start && first->when < end) {
|
if (past_start) {
|
||||||
|
|
||||||
x = first->when;
|
x = first->when;
|
||||||
y = first->value;
|
y = first->value;
|
||||||
|
|
@ -990,10 +982,9 @@ ControlList::rt_safe_earliest_event_discrete_unlocked (double start, double end,
|
||||||
/* Move left of cache to this point
|
/* Move left of cache to this point
|
||||||
* (Optimize for immediate call this cycle within range) */
|
* (Optimize for immediate call this cycle within range) */
|
||||||
_search_cache.left = x;
|
_search_cache.left = x;
|
||||||
++_search_cache.range.first;
|
++_search_cache.first;
|
||||||
|
|
||||||
assert(x >= start);
|
assert(x >= start);
|
||||||
assert(x < end);
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1014,7 +1005,7 @@ ControlList::rt_safe_earliest_event_discrete_unlocked (double start, double end,
|
||||||
* \return true if event is found (and \a x and \a y are valid).
|
* \return true if event is found (and \a x and \a y are valid).
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
ControlList::rt_safe_earliest_event_linear_unlocked (double start, double end, double& x, double& y, bool inclusive) const
|
ControlList::rt_safe_earliest_event_linear_unlocked (double start, double& x, double& y, bool inclusive) const
|
||||||
{
|
{
|
||||||
//cerr << "earliest_event(start: " << start << ", end: " << end
|
//cerr << "earliest_event(start: " << start << ", end: " << end
|
||||||
//<< ", x: " << x << ", y: " << y << ", inclusive: " << inclusive << ")" << endl;
|
//<< ", x: " << x << ", y: " << y << ", inclusive: " << inclusive << ")" << endl;
|
||||||
|
|
@ -1023,31 +1014,28 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double end, d
|
||||||
if (_events.empty()) { // 0 events
|
if (_events.empty()) { // 0 events
|
||||||
return false;
|
return false;
|
||||||
} else if (_events.end() == ++length_check_iter) { // 1 event
|
} else if (_events.end() == ++length_check_iter) { // 1 event
|
||||||
return rt_safe_earliest_event_discrete_unlocked(start, end, x, y, inclusive);
|
return rt_safe_earliest_event_discrete_unlocked (start, x, y, inclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hack to avoid infinitely repeating the same event
|
// Hack to avoid infinitely repeating the same event
|
||||||
build_search_cache_if_necessary(start, end);
|
build_search_cache_if_necessary (start);
|
||||||
|
|
||||||
pair<const_iterator,const_iterator> range = _search_cache.range;
|
if (_search_cache.first != _events.end()) {
|
||||||
|
|
||||||
if (range.first != _events.end()) {
|
|
||||||
|
|
||||||
const ControlEvent* first = NULL;
|
const ControlEvent* first = NULL;
|
||||||
const ControlEvent* next = NULL;
|
const ControlEvent* next = NULL;
|
||||||
|
|
||||||
/* Step is after first */
|
/* Step is after first */
|
||||||
if (range.first == _events.begin() || (*range.first)->when == start) {
|
if (_search_cache.first == _events.begin() || (*_search_cache.first)->when == start) {
|
||||||
first = *range.first;
|
first = *_search_cache.first;
|
||||||
next = *(++range.first);
|
next = *(++_search_cache.first);
|
||||||
++_search_cache.range.first;
|
|
||||||
|
|
||||||
/* Step is before first */
|
/* Step is before first */
|
||||||
} else {
|
} else {
|
||||||
const_iterator prev = range.first;
|
const_iterator prev = _search_cache.first;
|
||||||
--prev;
|
--prev;
|
||||||
first = *prev;
|
first = *prev;
|
||||||
next = *range.first;
|
next = *_search_cache.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inclusive && first->when == start) {
|
if (inclusive && first->when == start) {
|
||||||
|
|
@ -1062,7 +1050,7 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double end, d
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fabs(first->value - next->value) <= 1) {
|
if (fabs(first->value - next->value) <= 1) {
|
||||||
if (next->when <= end && (next->when > start)) {
|
if (next->when > start) {
|
||||||
x = next->when;
|
x = next->when;
|
||||||
y = next->value;
|
y = next->value;
|
||||||
/* Move left of cache to this point
|
/* Move left of cache to this point
|
||||||
|
|
@ -1108,7 +1096,7 @@ ControlList::rt_safe_earliest_event_linear_unlocked (double start, double end, d
|
||||||
|
|
||||||
|
|
||||||
const bool past_start = (inclusive ? x >= start : x > start);
|
const bool past_start = (inclusive ? x >= start : x > start);
|
||||||
if (past_start && x < end) {
|
if (past_start) {
|
||||||
/* Move left of cache to this point
|
/* Move left of cache to this point
|
||||||
* (Optimize for immediate call this cycle within range) */
|
* (Optimize for immediate call this cycle within range) */
|
||||||
_search_cache.left = x;
|
_search_cache.left = x;
|
||||||
|
|
|
||||||
|
|
@ -102,9 +102,9 @@ Sequence<Time>::const_iterator::const_iterator(const Sequence<Time>& seq, Time t
|
||||||
double x, y;
|
double x, y;
|
||||||
bool ret;
|
bool ret;
|
||||||
if (_force_discrete) {
|
if (_force_discrete) {
|
||||||
ret = i->second->list()->rt_safe_earliest_event_discrete_unlocked (t, DBL_MAX, x, y, true);
|
ret = i->second->list()->rt_safe_earliest_event_discrete_unlocked (t, x, y, true);
|
||||||
} else {
|
} else {
|
||||||
ret = i->second->list()->rt_safe_earliest_event_unlocked(t, DBL_MAX, x, y, true);
|
ret = i->second->list()->rt_safe_earliest_event_unlocked(t, x, y, true);
|
||||||
}
|
}
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
DEBUG_TRACE (DEBUG::Sequence, string_compose ("Iterator: CC %1 (size %2) has no events past %3\n",
|
DEBUG_TRACE (DEBUG::Sequence, string_compose ("Iterator: CC %1 (size %2) has no events past %3\n",
|
||||||
|
|
@ -253,9 +253,9 @@ Sequence<Time>::const_iterator::operator++()
|
||||||
case CONTROL:
|
case CONTROL:
|
||||||
// Increment current controller iterator
|
// Increment current controller iterator
|
||||||
if (_force_discrete) {
|
if (_force_discrete) {
|
||||||
ret = _control_iter->list->rt_safe_earliest_event_discrete_unlocked (_control_iter->x, DBL_MAX, x, y, false);
|
ret = _control_iter->list->rt_safe_earliest_event_discrete_unlocked (_control_iter->x, x, y, false);
|
||||||
} else {
|
} else {
|
||||||
ret = _control_iter->list->rt_safe_earliest_event_unlocked (_control_iter->x, DBL_MAX, x, y, false);
|
ret = _control_iter->list->rt_safe_earliest_event_unlocked (_control_iter->x, x, y, false);
|
||||||
}
|
}
|
||||||
assert(!ret || x > _control_iter->x);
|
assert(!ret || x > _control_iter->x);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue