Added cache for filenames; removed unneded scope creation.
h3rald h3rald@h3rald.com
Wed, 03 Jun 2026 10:32:37 +0200
5 files changed,
17 insertions(+),
5 deletions(-)
M
minpkg/core/env.nim
→
minpkg/core/env.nim
@@ -1,5 +1,6 @@
import std/os, + std/critbits, minline var HOME* {.threadvar.}: string@@ -26,3 +27,4 @@ var COLOR* {.threadvar.}: bool
COLOR = true var ERRORS_HANDLED* {.threadvar.}: bool ERRORS_HANDLED = false +var FILECACHE* {.threadvar.}: CritBitTree[string]
M
minpkg/core/interpreter.nim
→
minpkg/core/interpreter.nim
@@ -212,8 +212,7 @@ else:
op.prc(i) else: if op.val.kind == minQuotation and op.lambda: - var newscope = newScopeRef(i.scope) - i.withScope(newscope): + i.withScope(): for e in op.val.qVal: if e.isSymbol and e.symVal == sym: raiseInvalid("Symbol '$#' evaluates to itself" % sym)
M
minpkg/core/parser.nim
→
minpkg/core/parser.nim
@@ -9,6 +9,7 @@ logging,
json] import + env, baseutils import std/unicode except strip@@ -167,6 +168,12 @@ raiseInvalid("dVal - Dictionary expected, got " & $v.kind)
if v.scope.isNil: return CritBitTree[MinOperator]() return v.scope.symbols + +proc internFile*(s: string): string = + if FILECACHE.hasKey(s): + return FILECACHE[s] + FILECACHE[s] = s + return s const errorMessages: array[MinParserError, string] = [@@ -792,7 +799,7 @@ raiseInvalid("Invalid dictionary")
result = MinValue(kind: minDictionary, scope: scope) of tkSymbol: result = MinValue(kind: minSymbol, symVal: p.a, column: p.getColumn, - line: p.lineNumber, filename: p.filename) + line: p.lineNumber, filename: internFile(p.filename)) p.a = "" p.currSym = result discard getToken(p)
M
minpkg/lib/min_global.nim
→
minpkg/lib/min_global.nim
@@ -356,7 +356,8 @@ var endSnapshot: seq[MinValue]
var snapShot: seq[MinValue] try: snapshot = deepCopy(i.stack) - i.dequote bv + for v in bv.qVal: # execute directly in the existing scope (withScope) + i.push v endSnapshot = i.stack let d = snapshot.diff(endSnapshot) if d.len > 0:@@ -365,7 +366,8 @@ except MinReturnException:
discard else: try: - i.dequote bv + for v in bv.qVal: # execute directly in the existing scope (withScope) + i.push v except MinReturnException: discard # Validate output
M
next-release.md
→
next-release.md
@@ -7,5 +7,7 @@
* Ensure the relevant procs are gcsafe. * No longer using ref for `MinValue` objects. * No longer performing a deep copy when dequoting. +* Optimized the way debug information is stored to reduce memory usage. +* Avoiding creating unnecessary scopes when possible (withScope macro already creates a scope).