diff options
author | David Robillard <d@drobilla.net> | 2022-11-07 06:48:19 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-11-07 06:56:07 -0500 |
commit | 459805cef11dee2f0f7ef45b4a0b5853ae42954a (patch) | |
tree | 6979566c6c188ac1a91271fb4e8b30960a05d36b | |
parent | 205f6587600f91ea0710785cf87a2a71a3dac5ab (diff) | |
download | chilbert-459805cef11dee2f0f7ef45b4a0b5853ae42954a.tar.gz chilbert-459805cef11dee2f0f7ef45b4a0b5853ae42954a.tar.bz2 chilbert-459805cef11dee2f0f7ef45b4a0b5853ae42954a.zip |
Avoid raw new/delete
-rw-r--r-- | include/chilbert/chilbert.ipp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/include/chilbert/chilbert.ipp b/include/chilbert/chilbert.ipp index e53270f..8eda120 100644 --- a/include/chilbert/chilbert.ipp +++ b/include/chilbert/chilbert.ipp @@ -305,21 +305,19 @@ coords_to_compact_index(const P& p, // If we could avoid allocation altogether (ie: have a // fixed buffer allocated on the stack) then this increases // speed by a bit (4% when n=4, m=20) - auto* const ds = new size_t[m]; + const auto ds = std::make_unique<size_t[]>(m); if (mn > SmallBitVec::bits_per_rack) { DynamicBitVec h(mn); detail::coords_to_index<P, DynamicBitVec, I>( - p, m, n, h, std::forward<I>(scratch), ds); - compact_index<DynamicBitVec, HC>(ms, ds, n, m, h, hc); + p, m, n, h, std::forward<I>(scratch), ds.get()); + compact_index<DynamicBitVec, HC>(ms, ds.get(), n, m, h, hc); } else { SmallBitVec h(mn); detail::coords_to_index<P, SmallBitVec, I>( - p, m, n, h, std::forward<I>(scratch), ds); - compact_index<SmallBitVec, HC>(ms, ds, n, m, h, hc); + p, m, n, h, std::forward<I>(scratch), ds.get()); + compact_index<SmallBitVec, HC>(ms, ds.get(), n, m, h, hc); } - - delete[] ds; } template<class P, class HC, class I> |