summary refs log tree commit diff stats
path: root/lib/pure/collections
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-07-29 22:18:27 +0800
committerGitHub <noreply@github.com>2020-07-29 16:18:27 +0200
commitc645dba038f3d801afe1b9c842bd49bd9455b410 (patch)
tree1e4ccf3b0937334fe384b593ceeb7eb6e9b1c3dc /lib/pure/collections
parent2629d619a114f9c27b753a32da717a25906c99e6 (diff)
downloadNim-c645dba038f3d801afe1b9c842bd49bd9455b410.tar.gz
fixes #14139 (#15107)
* fix #14139
* Update lib/pure/collections/heapqueue.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: Clyybber <darkmine956@gmail.com>
Diffstat (limited to 'lib/pure/collections')
-rw-r--r--lib/pure/collections/heapqueue.nim6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/pure/collections/heapqueue.nim b/lib/pure/collections/heapqueue.nim
index 608fd2920..c2952cf1b 100644
--- a/lib/pure/collections/heapqueue.nim
+++ b/lib/pure/collections/heapqueue.nim
@@ -156,10 +156,10 @@ proc replace*[T](heap: var HeapQueue[T], item: T): T =
 
 proc pushpop*[T](heap: var HeapQueue[T], item: T): T =
   ## Fast version of a push followed by a pop.
-  if heap.len > 0 and heapCmp(heap[0], item):
-    swap(item, heap[0])
+  result = item
+  if heap.len > 0 and heapCmp(heap.data[0], item):
+    swap(result, heap.data[0])
     siftup(heap, 0)
-  return item
 
 proc clear*[T](heap: var HeapQueue[T]) =
   ## Remove all elements from `heap`, making it empty.