diff options
author | Chris Robinson <[email protected]> | 2019-09-01 17:54:17 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-09-01 17:54:17 -0700 |
commit | bb35e24c9ba7ec01c05fc1f07ef737c15821283a (patch) | |
tree | 446a56e69f7cce88a07ada7848298cdfbc9a775a | |
parent | 727217ce0a9765270551ad6e10a25ee0b7fb74e6 (diff) |
Avoid unnecessary placement new definitions
-rw-r--r-- | al/auxeffectslot.cpp | 7 | ||||
-rw-r--r-- | al/auxeffectslot.h | 2 | ||||
-rw-r--r-- | al/source.cpp | 7 | ||||
-rw-r--r-- | alc/alc.cpp | 3 |
4 files changed, 4 insertions, 15 deletions
diff --git a/al/auxeffectslot.cpp b/al/auxeffectslot.cpp index b2f2c249..3eb8b80a 100644 --- a/al/auxeffectslot.cpp +++ b/al/auxeffectslot.cpp @@ -173,13 +173,9 @@ ALeffectslot *AllocEffectSlot(ALCcontext *context) { return entry.FreeMask != 0; } ); auto lidx = static_cast<ALsizei>(std::distance(context->mEffectSlotList.begin(), sublist)); - ALeffectslot *slot; ALsizei slidx; if LIKELY(sublist != context->mEffectSlotList.end()) - { slidx = CTZ64(sublist->FreeMask); - slot = sublist->EffectSlots + slidx; - } else { /* Don't allocate so many list entries that the 32-bit ID could @@ -203,10 +199,9 @@ ALeffectslot *AllocEffectSlot(ALCcontext *context) } slidx = 0; - slot = sublist->EffectSlots + slidx; } - slot = new (slot) ALeffectslot{}; + ALeffectslot *slot{::new (sublist->EffectSlots + slidx) ALeffectslot{}}; ALenum err{InitEffectSlot(slot)}; if(err != AL_NO_ERROR) { diff --git a/al/auxeffectslot.h b/al/auxeffectslot.h index a6eb94f9..2471447f 100644 --- a/al/auxeffectslot.h +++ b/al/auxeffectslot.h @@ -92,7 +92,7 @@ struct ALeffectslot { static ALeffectslotArray *CreatePtrArray(size_t count) noexcept; - DEF_PLACE_NEWDEL() + DEF_NEWDEL(ALeffectslot) }; ALenum InitEffectSlot(ALeffectslot *slot); diff --git a/al/source.cpp b/al/source.cpp index 010dee1c..86a7d94c 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -491,13 +491,9 @@ ALsource *AllocSource(ALCcontext *context) { return entry.FreeMask != 0; } ); auto lidx = static_cast<ALsizei>(std::distance(context->mSourceList.begin(), sublist)); - ALsource *source; ALsizei slidx; if LIKELY(sublist != context->mSourceList.end()) - { slidx = CTZ64(sublist->FreeMask); - source = sublist->Sources + slidx; - } else { /* Don't allocate so many list entries that the 32-bit ID could @@ -521,10 +517,9 @@ ALsource *AllocSource(ALCcontext *context) } slidx = 0; - source = sublist->Sources + slidx; } - source = new (source) ALsource{device->NumAuxSends}; + ALsource *source{::new (sublist->Sources + slidx) ALsource{device->NumAuxSends}}; /* Add 1 to avoid source ID 0. */ source->id = ((lidx<<6) | slidx) + 1; diff --git a/alc/alc.cpp b/alc/alc.cpp index 8ee762d5..7964a2b3 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -2422,8 +2422,7 @@ void ALCcontext::init() { if(DefaultEffect.type != AL_EFFECT_NULL && mDevice->Type == Playback) { - void *ptr{al_calloc(16, sizeof(ALeffectslot))}; - mDefaultSlot = std::unique_ptr<ALeffectslot>{new (ptr) ALeffectslot{}}; + mDefaultSlot = std::unique_ptr<ALeffectslot>{new ALeffectslot{}}; if(InitEffectSlot(mDefaultSlot.get()) == AL_NO_ERROR) aluInitEffectPanning(mDefaultSlot.get(), mDevice.get()); else |