about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/utils/eprint.nim56
1 files changed, 23 insertions, 33 deletions
diff --git a/src/utils/eprint.nim b/src/utils/eprint.nim
index fab56464..02072bc6 100644
--- a/src/utils/eprint.nim
+++ b/src/utils/eprint.nim
@@ -1,38 +1,28 @@
 {.used.}
 
-func eprint*(s: varargs[string, `$`]) = {.cast(noSideEffect), cast(tags: []), cast(raises: []).}:
-  var a = false
-  var o = ""
-  when nimVm:
-    for x in s:
-      if not a:
-        a = true
-      else:
+func eprint*(s: varargs[string, `$`]) =
+  {.cast(noSideEffect), cast(tags: []), cast(raises: []).}:
+    var o = ""
+    for i in 0 ..< s.len:
+      if i != 0:
         o &= ' '
-      o &= x
-    echo o
-  else:
-    for x in s:
-      if not a:
-        a = true
-      else:
+      o &= s[i]
+    when nimVm:
+      echo o
+    else:
+      o &= '\n'
+      stderr.write(o)
+
+func elog*(s: varargs[string, `$`]) =
+  {.cast(noSideEffect), cast(tags: []), cast(raises: []).}:
+    var f: File
+    if not open(f, "a", fmAppend):
+      return
+    var o = ""
+    for i in 0 ..< s.len:
+      if i != 0:
         o &= ' '
-      o &= x
+      o &= s[i]
     o &= '\n'
-    stderr.write(o)
-
-func elog*(s: varargs[string, `$`]) = {.cast(noSideEffect), cast(tags: []), cast(raises: []).}:
-  var f: File
-  if not open(f, "a", fmAppend):
-    return
-  var a = false
-  var o = ""
-  for x in s:
-    if not a:
-      a = true
-    else:
-      o &= ' '
-    o &= x
-  o &= '\n'
-  f.write(o)
-  close(f)
+    f.write(o)
+    close(f)