diff options
-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> |