summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorrockcavera <rockcavera@gmail.com>2022-01-03 16:14:08 -0300
committerGitHub <noreply@github.com>2022-01-03 20:14:08 +0100
commit526a32e1697489b73e54c1b984ba5413842f1252 (patch)
tree1ee422db0677e78ea8338045a14af4410df5cf30 /lib/pure
parent19bcb43a0e21dd222ffd3fad8c5fb2d8e85d59ea (diff)
downloadNim-526a32e1697489b73e54c1b984ba5413842f1252.tar.gz
Fix #19314 - fixing broken `DoublyLinkedList` after adding empty `DoublyLinkedList` (#19315) [backport]
* Update lists.nim

* Update tlists.nim
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/collections/lists.nim12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/pure/collections/lists.nim b/lib/pure/collections/lists.nim
index de5550d6e..f7627ae67 100644
--- a/lib/pure/collections/lists.nim
+++ b/lib/pure/collections/lists.nim
@@ -675,12 +675,12 @@ proc addMoved*[T](a, b: var DoublyLinkedList[T]) {.since: (1, 5, 1).} =
     assert s == [0, 1, 0, 1, 0, 1]
 
   if b.head != nil:
-    b.head.prev = a.tail
-  if a.tail != nil:
-    a.tail.next = b.head
-  a.tail = b.tail
-  if a.head == nil:
-    a.head = b.head
+    if a.head == nil:
+      a.head = b.head
+    else:
+      b.head.prev = a.tail
+      a.tail.next = b.head
+    a.tail = b.tail
   if a.addr != b.addr:
     b.head = nil
     b.tail = nil