Skip to content

Commit ffbfce6

Browse files
committed
fix kil_helper to avoid in-place std::move calls which breack nanobind ref counting (and perhaps other similar objects)
1 parent 4fda055 commit ffbfce6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kll/include/kll_helper_impl.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ kll_helper::compress_result kll_helper::general_compress(uint16_t k, uint8_t m,
230230
// move level over as is
231231
// make sure we are not moving data upwards
232232
if (raw_beg < out_levels[current_level]) throw std::logic_error("wrong move");
233-
std::move(items + raw_beg, items + raw_lim, items + out_levels[current_level]);
233+
if (raw_beg != out_levels[current_level])
234+
std::move(items + raw_beg, items + raw_lim, items + out_levels[current_level]);
234235
out_levels[current_level + 1] = out_levels[current_level] + raw_pop;
235236
} else {
236237
// 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,
243244
const auto half_adj_pop = adj_pop / 2;
244245

245246
if (odd_pop) { // move one guy over
246-
items[out_levels[current_level]] = std::move(items[raw_beg]);
247+
if (out_levels[current_level] != raw_beg)
248+
items[out_levels[current_level]] = std::move(items[raw_beg]);
247249
out_levels[current_level + 1] = out_levels[current_level] + 1;
248250
} else { // even number of items
249251
out_levels[current_level + 1] = out_levels[current_level];

0 commit comments

Comments
 (0)