You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by jm...@apache.org on 2023/12/14 07:28:40 UTC

(datasketches-cpp) 02/03: fix kil_helper to avoid in-place std::move calls which breack nanobind ref counting (and perhaps other similar objects)

This is an automated email from the ASF dual-hosted git repository.

jmalkin pushed a commit to branch 5.0.1_patch
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git

commit ffbfce6686c3f9dfeb27a9f0584a67e698838b68
Author: Jon Malkin <78...@users.noreply.github.com>
AuthorDate: Fri Dec 1 20:49:34 2023 -0800

    fix kil_helper to avoid in-place std::move calls which breack nanobind ref counting (and perhaps other similar objects)
---
 kll/include/kll_helper_impl.hpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kll/include/kll_helper_impl.hpp b/kll/include/kll_helper_impl.hpp
index e763c57..bb92bdc 100644
--- a/kll/include/kll_helper_impl.hpp
+++ b/kll/include/kll_helper_impl.hpp
@@ -230,7 +230,8 @@ kll_helper::compress_result kll_helper::general_compress(uint16_t k, uint8_t m,
       // move level over as is
       // make sure we are not moving data upwards
       if (raw_beg < out_levels[current_level]) throw std::logic_error("wrong move");
-      std::move(items + raw_beg, items + raw_lim, items + out_levels[current_level]);
+      if (raw_beg != out_levels[current_level])
+        std::move(items + raw_beg, items + raw_lim, items + out_levels[current_level]);
       out_levels[current_level + 1] = out_levels[current_level] + raw_pop;
     } else {
       // The sketch is too full AND this level is too full, so we compact it
@@ -243,7 +244,8 @@ kll_helper::compress_result kll_helper::general_compress(uint16_t k, uint8_t m,
       const auto half_adj_pop = adj_pop / 2;
 
       if (odd_pop) { // move one guy over
-        items[out_levels[current_level]] = std::move(items[raw_beg]);
+        if (out_levels[current_level] != raw_beg)
+          items[out_levels[current_level]] = std::move(items[raw_beg]);
         out_levels[current_level + 1] = out_levels[current_level] + 1;
       } else { // even number of items
         out_levels[current_level + 1] = out_levels[current_level];


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org