summary refs log tree commit diff stats
path: root/lib/system
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-12-13 00:58:37 +0100
committerAraq <rumpf_a@web.de>2011-12-13 00:58:37 +0100
commit081ef4334cdc49b4ca24917f198ba7c33643cf77 (patch)
treea8107a8edb0424defca4e3b73f2454d3ff5270ef /lib/system
parent31ce41598ea14ee728e0936d7bc1e271fc69a2f4 (diff)
downloadNim-081ef4334cdc49b4ca24917f198ba7c33643cf77.tar.gz
GC: some inlining to improve performance sensitive parts
Diffstat (limited to 'lib/system')
-rwxr-xr-xlib/system/gc.nim12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/system/gc.nim b/lib/system/gc.nim
index 8bda816dd..caab22e34 100755
--- a/lib/system/gc.nim
+++ b/lib/system/gc.nim
@@ -301,7 +301,16 @@ proc forAllSlotsAux(dest: pointer, n: ptr TNimNode, op: TWalkOp) =
   case n.kind
   of nkSlot: forAllChildrenAux(cast[pointer](d +% n.offset), n.typ, op)
   of nkList:
-    for i in 0..n.len-1: forAllSlotsAux(dest, n.sons[i], op)
+    for i in 0..n.len-1:
+      # inlined for speed
+      if n.sons[i].kind == nkSlot:
+        if n.sons[i].typ.kind in {tyRef, tyString, tySequence}:
+          doOperation(cast[ppointer](d +% n.sons[i].offset)[], op)
+        else:
+          forAllChildrenAux(cast[pointer](d +% n.sons[i].offset), 
+                            n.sons[i].typ, op)
+      else:
+        forAllSlotsAux(dest, n.sons[i], op)
   of nkCase:
     var m = selectBranch(dest, n)
     if m != nil: forAllSlotsAux(dest, m, op)
@@ -507,6 +516,7 @@ proc collectCycles(gch: var TGcHeap) =
   for c in elements(gch.cycleRoots):
     inc(tabSize)
     forallChildren(c, waCycleDecRef)
+  if tabSize == 0: return
   gch.stat.cycleTableSize = max(gch.stat.cycleTableSize, tabSize)
 
   # restore reference counts (a depth-first traversal is needed):