summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-03-29 09:05:45 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-03-29 09:05:45 +0200
commita88a9095654ec4c7f0dd803e164047a464fba829 (patch)
tree950f03530a25f183b52a2aa070a9d90f9a8c74f7 /lib
parentba8359831a229b41130cfeb61fbf5de6c6bd67cf (diff)
downloadNim-a88a9095654ec4c7f0dd803e164047a464fba829.tar.gz
fixes #5625
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/algorithm.nim16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/pure/algorithm.nim b/lib/pure/algorithm.nim
index bc39f153b..9eee04404 100644
--- a/lib/pure/algorithm.nim
+++ b/lib/pure/algorithm.nim
@@ -112,15 +112,17 @@ proc lowerBound*[T](a: openArray[T], key: T, cmp: proc(x,y: T): int {.closure.})
       count = step
 
 proc lowerBound*[T](a: openArray[T], key: T): int = lowerBound(a, key, cmp[T])
+
+template `<-` (a, b) =
+  when false:
+    a = b
+  elif onlySafeCode:
+    shallowCopy(a, b)
+  else:
+    copyMem(addr(a), addr(b), sizeof(T))
+
 proc merge[T](a, b: var openArray[T], lo, m, hi: int,
               cmp: proc (x, y: T): int {.closure.}, order: SortOrder) =
-  template `<-` (a, b) =
-    when false:
-      a = b
-    elif onlySafeCode:
-      shallowCopy(a, b)
-    else:
-      copyMem(addr(a), addr(b), sizeof(T))
   # optimization: If max(left) <= min(right) there is nothing to do!
   # 1 2 3 4  ## 5 6 7 8
   # -> O(n) for sorted arrays.