From 4af1af70ad41015d0126837e856d87b930f61655 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 29 Oct 2017 04:42:58 +1100 Subject: BLI_hash: add BLI_heap_reinsert Allows avoiding remove/insert calls. --- source/blender/blenlib/intern/BLI_heap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/blender/blenlib/intern/BLI_heap.c') diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c index 6b3d797a485..d794332b5df 100644 --- a/source/blender/blenlib/intern/BLI_heap.c +++ b/source/blender/blenlib/intern/BLI_heap.c @@ -306,6 +306,16 @@ void *BLI_heap_popmin(Heap *heap) return ptr; } +void BLI_heap_reinsert(Heap *heap, HeapNode *node, float value) +{ + if (value == node->value) { + return; + } + node->value = value; + heap_up(heap, node->index); + heap_down(heap, node->index); +} + void BLI_heap_remove(Heap *heap, HeapNode *node) { uint i = node->index; -- cgit v1.2.3