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

@@ -17,7 +17,7 @@ when defined(nimPreviewSlimSystem):
import
options, ast, msgs, idents, renderer,
magicsys, vmdef, modulegraphs, lineinfos, pathutils, layeredtable,
types, lowerings, trees, parampatterns
types, lowerings, trees, parampatterns, astalgo
import ic / ic
@@ -42,7 +42,7 @@ type
breakInLoop*: bool # whether we are in a loop without block
next*: PProcCon # used for stacking procedure contexts
mappingExists*: bool
mapping*: Table[ItemId, PSym]
mapping*: SymMapping
caseContext*: seq[tuple[n: PNode, idx: int]]
localBindStmts*: seq[PNode]
@@ -258,7 +258,7 @@ proc popProcCon*(c: PContext) {.inline.} = c.p = c.p.next
proc put*(p: PProcCon; key, val: PSym) =
if not p.mappingExists:
p.mapping = initTable[ItemId, PSym]()
p.mapping = initSymMapping()
p.mappingExists = true
#echo "put into table ", key.info
p.mapping[key.itemId] = val