try to optimize hot spots for orc-booting compiler (#20001)

* optimize hot spots fro orc-booting compiler

* remove GC_ref

* minor

* remove comments

* Revert "minor"

This reverts commit 4965a190a2.

* emulate cursor
This commit is contained in:
flywind
2022-07-12 19:07:18 +08:00
committed by GitHub
parent d0bae989d6
commit a97b00ad8d

View File

@@ -18,6 +18,9 @@ import
when defined(nimPreviewSlimSystem):
import std/assertions
when not defined(nimHasCursor):
{.pragma: cursor.}
proc hashNode*(p: RootRef): Hash
proc treeToYaml*(conf: ConfigRef; n: PNode, indent: int = 0, maxRecDepth: int = - 1): Rope
# Convert a tree into its YAML representation; this is used by the
@@ -815,16 +818,21 @@ type
name*: PIdent
proc nextIdentIter*(ti: var TIdentIter, tab: TStrTable): PSym =
# hot spots
var h = ti.h and high(tab.data)
var start = h
result = tab.data[h]
while result != nil:
if result.name.id == ti.name.id: break
var p {.cursor.} = tab.data[h]
while p != nil:
if p.name.id == ti.name.id: break
h = nextTry(h, high(tab.data))
if h == start:
result = nil
p = nil
break
result = tab.data[h]
p = tab.data[h]
if p != nil:
result = p # increase the count
else:
result = nil
ti.h = nextTry(h, high(tab.data))
proc initIdentIter*(ti: var TIdentIter, tab: TStrTable, s: PIdent): PSym =