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 4965a190a2d6457044faa1442795e55bdad57602. * emulate cursor
This commit is contained in:
parent
d0bae989d6
commit
a97b00ad8d
1 changed files with 13 additions and 5 deletions
|
|
@ -18,6 +18,9 @@ import
|
||||||
when defined(nimPreviewSlimSystem):
|
when defined(nimPreviewSlimSystem):
|
||||||
import std/assertions
|
import std/assertions
|
||||||
|
|
||||||
|
when not defined(nimHasCursor):
|
||||||
|
{.pragma: cursor.}
|
||||||
|
|
||||||
proc hashNode*(p: RootRef): Hash
|
proc hashNode*(p: RootRef): Hash
|
||||||
proc treeToYaml*(conf: ConfigRef; n: PNode, indent: int = 0, maxRecDepth: int = - 1): Rope
|
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
|
# Convert a tree into its YAML representation; this is used by the
|
||||||
|
|
@ -815,16 +818,21 @@ type
|
||||||
name*: PIdent
|
name*: PIdent
|
||||||
|
|
||||||
proc nextIdentIter*(ti: var TIdentIter, tab: TStrTable): PSym =
|
proc nextIdentIter*(ti: var TIdentIter, tab: TStrTable): PSym =
|
||||||
|
# hot spots
|
||||||
var h = ti.h and high(tab.data)
|
var h = ti.h and high(tab.data)
|
||||||
var start = h
|
var start = h
|
||||||
result = tab.data[h]
|
var p {.cursor.} = tab.data[h]
|
||||||
while result != nil:
|
while p != nil:
|
||||||
if result.name.id == ti.name.id: break
|
if p.name.id == ti.name.id: break
|
||||||
h = nextTry(h, high(tab.data))
|
h = nextTry(h, high(tab.data))
|
||||||
if h == start:
|
if h == start:
|
||||||
result = nil
|
p = nil
|
||||||
break
|
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))
|
ti.h = nextTry(h, high(tab.data))
|
||||||
|
|
||||||
proc initIdentIter*(ti: var TIdentIter, tab: TStrTable, s: PIdent): PSym =
|
proc initIdentIter*(ti: var TIdentIter, tab: TStrTable, s: PIdent): PSym =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue