From 459805cef11dee2f0f7ef45b4a0b5853ae42954a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 7 Nov 2022 06:48:19 -0500 Subject: Avoid raw new/delete --- include/chilbert/chilbert.ipp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'include/chilbert') 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(m); if (mn > SmallBitVec::bits_per_rack) { DynamicBitVec h(mn); detail::coords_to_index( - p, m, n, h, std::forward(scratch), ds); - compact_index(ms, ds, n, m, h, hc); + p, m, n, h, std::forward(scratch), ds.get()); + compact_index(ms, ds.get(), n, m, h, hc); } else { SmallBitVec h(mn); detail::coords_to_index( - p, m, n, h, std::forward(scratch), ds); - compact_index(ms, ds, n, m, h, hc); + p, m, n, h, std::forward(scratch), ds.get()); + compact_index(ms, ds.get(), n, m, h, hc); } - - delete[] ds; } template -- cgit v1.2.1