summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2019-04-06 20:14:05 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2019-04-06 20:14:44 +0200
commitaa6ef7e42966e36db74a4d15367379cbff37bbc8 (patch)
tree4879f689c530feda0d87b9ec0c97d8b8444ff76a /src
parentd0b501dd1c0dd84428903cf08730838bb8889bbf (diff)
Avoid calling find on a map twice in midimap lookup.
Diffstat (limited to 'src')
-rw-r--r--src/midimapper.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/midimapper.cc b/src/midimapper.cc
index 9243ecf..9593aae 100644
--- a/src/midimapper.cc
+++ b/src/midimapper.cc
@@ -30,18 +30,19 @@ int MidiMapper::lookup(int note)
{
std::lock_guard<std::mutex> guard(mutex);
- if(midimap.find(note) == midimap.end())
+ auto midimap_it = midimap.find(note);
+ if(midimap_it == midimap.end())
{
return -1;
}
- const std::string& instr = midimap[note];
- if(instrmap.find(instr) == instrmap.end())
+ auto instrmap_it = instrmap.find(midimap_it->second);
+ if(instrmap_it == instrmap.end())
{
return -1;
}
- return instrmap[instr];
+ return instrmap_it->second;
}
void MidiMapper::swap(instrmap_t& instrmap, midimap_t& midimap)