From f94ac9c32b1597a87e4e5ddddccc61a31dfc87e8 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 19 Nov 2017 16:26:24 -0800 Subject: [PATCH] Use getSourceGroup and findSourceGroup to handle source group cache entries --- include/AL/alure2.h | 2 +- src/context.cpp | 10 +++++----- src/context.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/AL/alure2.h b/include/AL/alure2.h index 2e1a2e2..fa92801 100644 --- a/include/AL/alure2.h +++ b/include/AL/alure2.h @@ -645,8 +645,8 @@ public: Effect createEffect(); - SourceGroup createSourceGroup(StringView name); SourceGroup getSourceGroup(StringView name); + SourceGroup findSourceGroup(StringView name); /** Sets the doppler factor to apply to all source doppler calculations. */ void setDopplerFactor(ALfloat factor); diff --git a/src/context.cpp b/src/context.cpp index 8a6b085..7317001 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -1459,8 +1459,8 @@ Effect ContextImpl::createEffect() } -DECL_THUNK1(SourceGroup, Context, createSourceGroup,, StringView) -SourceGroup ContextImpl::createSourceGroup(StringView name) +DECL_THUNK1(SourceGroup, Context, getSourceGroup,, StringView) +SourceGroup ContextImpl::getSourceGroup(StringView name) { auto hasher = std::hash(); auto iter = std::lower_bound(mSourceGroups.begin(), mSourceGroups.end(), hasher(name), @@ -1468,13 +1468,13 @@ SourceGroup ContextImpl::createSourceGroup(StringView name) { return hasher(lhs->getName()) < rhs; } ); if(iter != mSourceGroups.end() && (*iter)->getName() == name) - throw std::runtime_error("Duplicate source group name"); + return SourceGroup(iter->get()); iter = mSourceGroups.insert(iter, MakeUnique(this, name)); return SourceGroup(iter->get()); } -DECL_THUNK1(SourceGroup, Context, getSourceGroup,, StringView) -SourceGroup ContextImpl::getSourceGroup(StringView name) +DECL_THUNK1(SourceGroup, Context, findSourceGroup,, StringView) +SourceGroup ContextImpl::findSourceGroup(StringView name) { auto hasher = std::hash(); auto iter = std::lower_bound(mSourceGroups.begin(), mSourceGroups.end(), hasher(name), diff --git a/src/context.h b/src/context.h index 6c314e1..6487a22 100644 --- a/src/context.h +++ b/src/context.h @@ -314,8 +314,8 @@ public: Effect createEffect(); - SourceGroup createSourceGroup(StringView name); SourceGroup getSourceGroup(StringView name); + SourceGroup findSourceGroup(StringView name); void setDopplerFactor(ALfloat factor); -- 2.11.4.GIT