bring back id table algorithm instead of std table [backport:2.2] (#24930)

refs #24929, partially reverts #23403

Instead of using `Table[ItemId, T]`, the old algorithm is brought back
into `TIdTable[T]` to prevent a performance regression. The inheritance
removal from #23403 still holds, only `ItemId`s are stored.

(cherry picked from commit 82553384d1)
This commit is contained in:
metagn
2025-05-06 10:36:20 +03:00
committed by narimiran
parent 39757d421e
commit c385fcb6be
7 changed files with 111 additions and 26 deletions

View File

@@ -40,7 +40,7 @@ import closureiters, lambdalifting
type
PTransCon = ref object # part of TContext; stackable
mapping: Table[ItemId, PNode] # mapping from symbols to nodes
mapping: TIdTable[PNode] # mapping from symbols to nodes
owner: PSym # current owner
forStmt: PNode # current for stmt
forLoopBody: PNode # transformed for loop body
@@ -78,7 +78,7 @@ proc newTransNode(kind: TNodeKind, n: PNode,
proc newTransCon(owner: PSym): PTransCon =
assert owner != nil
result = PTransCon(mapping: initTable[ItemId, PNode](), owner: owner)
result = PTransCon(mapping: initIdTable[PNode](), owner: owner)
proc pushTransCon(c: PTransf, t: PTransCon) =
t.next = c.transCon