From 5c1dccaca54b3ef834a0b4a09fc92b3e1b552eac Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 19 Oct 2009 15:44:58 +0000 Subject: [PATCH] Use logarithmic search for MidiModel::find_note (used by DiffCommand). git-svn-id: svn://localhost/ardour2/branches/3.0@5800 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/midi_model.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc index eb69a2a906..06beb4fa48 100644 --- a/libs/ardour/midi_model.cc +++ b/libs/ardour/midi_model.cc @@ -719,15 +719,10 @@ MidiModel::get_state() boost::shared_ptr > MidiModel::find_note (boost::shared_ptr > other) { - for (Notes::iterator x = notes().begin(); x != notes().end(); ++x) { - if (**x == *other) { - return *x; + for (Notes::iterator l = notes().lower_bound(other); (*l)->time() == other->time(); ++l) { + if (*l == other) { + return *l; } - - /* XXX optimize by using a stored iterator and break out - when passed start time. - */ } - - return boost::shared_ptr > (); + return boost::shared_ptr >(); }