From 48e86db1f4ebc85145d384ba061c4f615cb3106f Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 18 Apr 2022 20:59:12 -0400 Subject: [PATCH] tentative fix for #138 --- parallel_hashmap/btree.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/parallel_hashmap/btree.h b/parallel_hashmap/btree.h index 5f34f11..814f18a 100644 --- a/parallel_hashmap/btree.h +++ b/parallel_hashmap/btree.h @@ -2239,11 +2239,13 @@ namespace priv { // 1) Shift existing values in the right node to their correct positions. right->uninitialized_move_n(to_move, right->count() - to_move, right->count(), right, alloc); - for (slot_type *src = right->slot(right->count() - to_move - 1), - *dest = right->slot(right->count() - 1), - *end = right->slot(0); - src >= end; --src, --dest) { - params_type::move(alloc, src, dest); + if (right->count() > to_move) { + for (slot_type *src = right->slot(right->count() - to_move - 1), + *dest = right->slot(right->count() - 1), + *end = right->slot(0); + src >= end; --src, --dest) { + params_type::move(alloc, src, dest); + } } // 2) Move the delimiting value in the parent to the right node.