aboutsummaryrefslogtreecommitdiffstats
path: root/al
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-09-01 18:07:16 -0700
committerChris Robinson <[email protected]>2019-09-01 18:07:16 -0700
commit3d7ce5a86010240262bdd1763218b3beeda21c5e (patch)
treef42168fdf8df27bccb48f4e395d22705b4449219 /al
parentbb35e24c9ba7ec01c05fc1f07ef737c15821283a (diff)
Use global placement new for AL object batches
Diffstat (limited to 'al')
-rw-r--r--al/buffer.cpp8
-rw-r--r--al/effect.cpp9
-rw-r--r--al/filter.cpp7
3 files changed, 5 insertions, 19 deletions
diff --git a/al/buffer.cpp b/al/buffer.cpp
index df2496cb..03b68038 100644
--- a/al/buffer.cpp
+++ b/al/buffer.cpp
@@ -254,13 +254,9 @@ ALbuffer *AllocBuffer(ALCcontext *context)
);
auto lidx = static_cast<ALsizei>(std::distance(device->BufferList.begin(), sublist));
- ALbuffer *buffer{nullptr};
ALsizei slidx{0};
if LIKELY(sublist != device->BufferList.end())
- {
slidx = CTZ64(sublist->FreeMask);
- buffer = sublist->Buffers + slidx;
- }
else
{
/* Don't allocate so many list entries that the 32-bit ID could
@@ -283,10 +279,10 @@ ALbuffer *AllocBuffer(ALCcontext *context)
}
slidx = 0;
- buffer = sublist->Buffers + slidx;
}
- buffer = new (buffer) ALbuffer{};
+ ALbuffer *buffer{::new (sublist->Buffers + slidx) ALbuffer{}};
+
/* Add 1 to avoid buffer ID 0. */
buffer->id = ((lidx<<6) | slidx) + 1;
diff --git a/al/effect.cpp b/al/effect.cpp
index e5571be0..3836a5e4 100644
--- a/al/effect.cpp
+++ b/al/effect.cpp
@@ -130,7 +130,7 @@ void InitEffectParams(ALeffect *effect, ALenum type)
}
else
{
- effect->Props = EffectProps {};
+ effect->Props = EffectProps{};
effect->vtab = nullptr;
}
effect->type = type;
@@ -146,13 +146,9 @@ ALeffect *AllocEffect(ALCcontext *context)
);
auto lidx = static_cast<ALsizei>(std::distance(device->EffectList.begin(), sublist));
- ALeffect *effect{nullptr};
ALsizei slidx{0};
if LIKELY(sublist != device->EffectList.end())
- {
slidx = CTZ64(sublist->FreeMask);
- effect = sublist->Effects + slidx;
- }
else
{
/* Don't allocate so many list entries that the 32-bit ID could
@@ -175,10 +171,9 @@ ALeffect *AllocEffect(ALCcontext *context)
}
slidx = 0;
- effect = sublist->Effects + slidx;
}
- effect = new (effect) ALeffect{};
+ ALeffect *effect{::new (sublist->Effects + slidx) ALeffect{}};
InitEffectParams(effect, AL_EFFECT_NULL);
/* Add 1 to avoid effect ID 0. */
diff --git a/al/filter.cpp b/al/filter.cpp
index b1118550..abb2795b 100644
--- a/al/filter.cpp
+++ b/al/filter.cpp
@@ -288,13 +288,9 @@ ALfilter *AllocFilter(ALCcontext *context)
);
auto lidx = static_cast<ALsizei>(std::distance(device->FilterList.begin(), sublist));
- ALfilter *filter{nullptr};
ALsizei slidx{0};
if LIKELY(sublist != device->FilterList.end())
- {
slidx = CTZ64(sublist->FreeMask);
- filter = sublist->Filters + slidx;
- }
else
{
/* Don't allocate so many list entries that the 32-bit ID could
@@ -317,10 +313,9 @@ ALfilter *AllocFilter(ALCcontext *context)
}
slidx = 0;
- filter = sublist->Filters + slidx;
}
- filter = new (filter) ALfilter{};
+ ALfilter *filter{::new (sublist->Filters + slidx) ALfilter{}};
InitFilterParams(filter, AL_FILTER_NULL);
/* Add 1 to avoid filter ID 0. */