summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorfowlmouth <phowl.mouth@gmail.com>2013-12-02 23:47:56 -0600
committerfowlmouth <phowl.mouth@gmail.com>2013-12-02 23:47:56 -0600
commit4f0eeaa55ef88fc61acf4dc67ddbae47d8fc8052 (patch)
tree080ac4a038d334ac9ebd42bc8f172952cc5e765f /compiler
parent6577093d2d318b6351984a9f8f8166c6f37c6525 (diff)
downloadNim-4f0eeaa55ef88fc61acf4dc67ddbae47d8fc8052.tar.gz
fixes compiler.lists.bringToFront
Diffstat (limited to 'compiler')
-rw-r--r--compiler/lists.nim18
1 files changed, 11 insertions, 7 deletions
diff --git a/compiler/lists.nim b/compiler/lists.nim
index 67b32f919..22b1a183a 100644
--- a/compiler/lists.nim
+++ b/compiler/lists.nim
@@ -91,13 +91,17 @@ proc Remove*(list: var TLinkedList, entry: PListEntry) =
   if entry.prev != nil: entry.prev.next = entry.next
 
 proc bringToFront*(list: var TLinkedList, entry: PListEntry) =
-  if entry == list.head: return
-  if entry == list.tail: list.tail = entry.prev
-  if entry.next != nil: entry.next.prev = entry.prev
-  if entry.prev != nil: entry.prev.next = entry.next
-  entry.prev = nil
-  entry.next = list.head
-  list.head = entry
+  when true:
+    list.remove entry
+    list.prepend entry
+  else:
+    if entry == list.head: return
+    if entry == list.tail: list.tail = entry.prev
+    if entry.next != nil: entry.next.prev = entry.prev
+    if entry.prev != nil: entry.prev.next = entry.next
+    entry.prev = nil
+    entry.next = list.head
+    list.head = entry
 
 proc ExcludeStr*(list: var TLinkedList, data: string) =
   var it = list.head