summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system')
-rw-r--r--lib/system/excpt.nim12
-rw-r--r--lib/system/repr.nim2
-rw-r--r--lib/system/reprjs.nim5
-rw-r--r--lib/system/sysio.nim8
-rw-r--r--lib/system/threads.nim5
5 files changed, 12 insertions, 20 deletions
diff --git a/lib/system/excpt.nim b/lib/system/excpt.nim
index 7b4979cfa..d9c7b4c25 100644
--- a/lib/system/excpt.nim
+++ b/lib/system/excpt.nim
@@ -213,7 +213,7 @@ proc auxWriteStackTrace(f: PFrame; s: var seq[StackTraceEntry]) =
     inc(i)
     it = it.prev
   var last = i-1
-  if s.isNil:
+  if s.len == 0:
     s = newSeq[StackTraceEntry](i)
   else:
     last = s.len + i - 1
@@ -361,10 +361,10 @@ proc raiseExceptionAux(e: ref Exception) =
     else:
       when hasSomeStackTrace:
         var buf = newStringOfCap(2000)
-        if isNil(e.trace): rawWriteStackTrace(buf)
+        if e.trace.len == 0: rawWriteStackTrace(buf)
         else: add(buf, $e.trace)
         add(buf, "Error: unhandled exception: ")
-        if not isNil(e.msg): add(buf, e.msg)
+        add(buf, e.msg)
         add(buf, " [")
         add(buf, $e.name)
         add(buf, "]\n")
@@ -382,7 +382,7 @@ proc raiseExceptionAux(e: ref Exception) =
         var buf: array[0..2000, char]
         var L = 0
         add(buf, "Error: unhandled exception: ")
-        if not isNil(e.msg): add(buf, e.msg)
+        add(buf, e.msg)
         add(buf, " [")
         xadd(buf, e.name, e.name.len)
         add(buf, "]\n")
@@ -397,7 +397,7 @@ proc raiseExceptionAux(e: ref Exception) =
 proc raiseException(e: ref Exception, ename: cstring) {.compilerRtl.} =
   if e.name.isNil: e.name = ename
   when hasSomeStackTrace:
-    if e.trace.isNil:
+    if e.trace.len == 0:
       rawWriteStackTrace(e.trace)
     elif framePtr != nil:
       e.trace.add reraisedFrom(reraisedFromBegin)
@@ -427,7 +427,7 @@ proc getStackTrace(): string =
     result = "No stack traceback available\n"
 
 proc getStackTrace(e: ref Exception): string =
-  if not isNil(e) and not isNil(e.trace):
+  if not isNil(e):
     result = $e.trace
   else:
     result = ""
diff --git a/lib/system/repr.nim b/lib/system/repr.nim
index 45acae7f1..3dc220b87 100644
--- a/lib/system/repr.nim
+++ b/lib/system/repr.nim
@@ -266,7 +266,7 @@ when not defined(useNimRtl):
     of tyChar: add result, reprChar(cast[ptr char](p)[])
     of tyString:
       let sp = cast[ptr string](p)
-      reprStrAux(result, if sp[].isNil: nil else: sp[].cstring, sp[].len)
+      reprStrAux(result, sp[].cstring, sp[].len)
     of tyCString:
       let cs = cast[ptr cstring](p)[]
       if cs.isNil: add result, "nil"
diff --git a/lib/system/reprjs.nim b/lib/system/reprjs.nim
index d04d6e12b..7cb25a252 100644
--- a/lib/system/reprjs.nim
+++ b/lib/system/reprjs.nim
@@ -232,10 +232,7 @@ proc reprAux(result: var string, p: pointer, typ: PNimType,
   of tyString:
     var fp: int
     {. emit: "`fp` = `p`;\n" .}
-    if cast[string](fp).isNil:
-      add(result, "nil")
-    else:
-      add( result, reprStr(cast[string](p)) )
+    add( result, reprStr(cast[string](p)) )
   of tyCString:
     var fp: cstring
     {. emit: "`fp` = `p`;\n" .}
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index 3168e4cb2..75e26a6c9 100644
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -144,13 +144,7 @@ proc getFileHandle*(f: File): FileHandle = c_fileno(f)
 proc readLine(f: File, line: var TaintedString): bool =
   var pos = 0
   var sp: cint = 80
-  # Use the currently reserved space for a first try
-  if line.string.isNil:
-    line = TaintedString(newStringOfCap(80))
-  else:
-    when not defined(nimscript) and not defined(gcDestructors):
-      sp = cint(cast[PGenericSeq](line.string).space)
-    line.string.setLen(sp)
+  line.string.setLen(sp)
   while true:
     # memset to \L so that we can tell how far fgets wrote, even on EOF, where
     # fgets doesn't append an \L
diff --git a/lib/system/threads.nim b/lib/system/threads.nim
index 2434ea21e..aaf0164fd 100644
--- a/lib/system/threads.nim
+++ b/lib/system/threads.nim
@@ -393,8 +393,9 @@ proc onThreadDestruction*(handler: proc () {.closure, gcsafe.}) =
   ## A thread is destructed when the ``.thread`` proc returns
   ## normally or when it raises an exception. Note that unhandled exceptions
   ## in a thread nevertheless cause the whole process to die.
-  if threadDestructionHandlers.isNil:
-    threadDestructionHandlers = @[]
+  when not defined(nimNoNilSeqs):
+    if threadDestructionHandlers.isNil:
+      threadDestructionHandlers = @[]
   threadDestructionHandlers.add handler
 
 template afterThreadRuns() =