aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-11-29 06:19:06 -0800
committerChris Robinson <[email protected]>2019-11-29 06:19:06 -0800
commit34edd3a9141775f04893fd56622f36a47af558b4 (patch)
treeb5786dbe213b4505b3fd198adeb9cfa0423315d0 /alc
parent7b3f88c4307f744b00d04ac2e88d7d31465f05bf (diff)
Fix sorting of loaded HRTFs
Diffstat (limited to 'alc')
-rw-r--r--alc/hrtf.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp
index 76263a79..96cd0b80 100644
--- a/alc/hrtf.cpp
+++ b/alc/hrtf.cpp
@@ -1271,20 +1271,18 @@ HrtfStore *GetLoadedHrtf(const std::string &name, const char *devname, const ALu
const std::string &fname = entry_iter->mFilename;
std::lock_guard<std::mutex> __{LoadedHrtfLock};
- auto handle = std::find_if(LoadedHrtfs.begin(), LoadedHrtfs.end(),
- [&fname](LoadedHrtf &hrtf) -> bool { return hrtf.mFilename == fname; }
+ auto handle = std::lower_bound(LoadedHrtfs.begin(), LoadedHrtfs.end(), fname,
+ [](LoadedHrtf &hrtf, const std::string &fname) -> bool { return hrtf.mFilename < fname; }
);
- if(handle != LoadedHrtfs.end())
+ while(handle != LoadedHrtfs.end() && handle->mFilename == fname)
{
- do {
- HrtfStore *hrtf{handle->mEntry.get()};
- if(hrtf && hrtf->sampleRate == devrate)
- {
- hrtf->IncRef();
- return hrtf;
- }
- ++handle;
- } while(handle != LoadedHrtfs.end() && handle->mFilename == fname);
+ HrtfStore *hrtf{handle->mEntry.get()};
+ if(hrtf && hrtf->sampleRate == devrate)
+ {
+ hrtf->IncRef();
+ return hrtf;
+ }
+ ++handle;
}
std::unique_ptr<std::istream> stream;
@@ -1395,9 +1393,9 @@ HrtfStore *GetLoadedHrtf(const std::string &name, const char *devname, const ALu
TRACE("Loaded HRTF %s for sample rate %uhz, %u-sample filter\n", name.c_str(),
hrtf->sampleRate, hrtf->irSize);
- LoadedHrtfs.emplace_back(LoadedHrtf{fname, std::move(hrtf)});
+ handle = LoadedHrtfs.emplace(handle, LoadedHrtf{fname, std::move(hrtf)});
- return LoadedHrtfs.back().mEntry.get();
+ return handle->mEntry.get();
}