mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-14 18:46:34 +01:00
Remove linear search when adding/removing a note from/to a Sequence.
git-svn-id: svn://localhost/ardour2/branches/3.0@5870 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
78b00fa6dc
commit
382a79eda5
1 changed files with 6 additions and 7 deletions
|
|
@ -707,9 +707,7 @@ Sequence<Time>::add_note_unlocked(const boost::shared_ptr< Note<Time> > note)
|
||||||
{
|
{
|
||||||
DUMP(format("%1% add note %2% @ %3%\n") % this % (int)note->note() % note->time());
|
DUMP(format("%1% add note %2% @ %3%\n") % this % (int)note->note() % note->time());
|
||||||
_edited = true;
|
_edited = true;
|
||||||
typename Notes::iterator i = upper_bound(_notes.begin(), _notes.end(), note,
|
_notes.insert(note);
|
||||||
note_time_comparator);
|
|
||||||
_notes.insert(i, note);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
|
|
@ -718,12 +716,13 @@ Sequence<Time>::remove_note_unlocked(const boost::shared_ptr< const Note<Time> >
|
||||||
{
|
{
|
||||||
_edited = true;
|
_edited = true;
|
||||||
DUMP(format("%1% remove note %2% @ %3%\n") % this % (int)note->note() % note->time());
|
DUMP(format("%1% remove note %2% @ %3%\n") % this % (int)note->note() % note->time());
|
||||||
for (typename Notes::iterator n = _notes.begin(); n != _notes.end(); ++n) {
|
for (typename Sequence<Time>::Notes::iterator i = note_lower_bound(note->time());
|
||||||
if (*(*n) == *note) {
|
i != _notes.end() && (*i)->time() == note->time(); ++i) {
|
||||||
_notes.erase(n);
|
if (*i == note) {
|
||||||
break;
|
_notes.erase(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cerr << "Unable to find note to erase" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Time>
|
template<typename Time>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue