replaces pairs with keys and items; saves 8 bytes (#21319)

replace `pairs` with `keys` and `items`
This commit is contained in:
ringabout
2023-02-03 02:11:20 +08:00
committed by GitHub
parent 17115cbc73
commit 8e53fba083
3 changed files with 5 additions and 5 deletions

View File

@@ -25,7 +25,7 @@ proc undefSymbol*(symbols: StringTableRef; symbol: string) =
# result = if isDefined(symbol): gSymbols[symbol] else: nil
iterator definedSymbolNames*(symbols: StringTableRef): string =
for key, val in pairs(symbols):
for key in keys(symbols):
yield key
proc countDefinedSymbols*(symbols: StringTableRef): int =

View File

@@ -685,7 +685,7 @@ proc getConstExpr(m: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNode
n[0] = a
of nkBracket, nkCurly:
result = copyNode(n)
for i, son in n.pairs:
for son in n.items:
var a = getConstExpr(m, son, idgen, g)
if a == nil: return nil
result.add a
@@ -709,7 +709,7 @@ proc getConstExpr(m: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNode
# tuple constructor
result = copyNode(n)
if (n.len > 0) and (n[0].kind == nkExprColonExpr):
for i, expr in n.pairs:
for expr in n.items:
let exprNew = copyNode(expr) # nkExprColonExpr
exprNew.add expr[0]
let a = getConstExpr(m, expr[1], idgen, g)
@@ -717,7 +717,7 @@ proc getConstExpr(m: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNode
exprNew.add a
result.add exprNew
else:
for i, expr in n.pairs:
for expr in n.items:
let a = getConstExpr(m, expr, idgen, g)
if a == nil: return nil
result.add a

View File

@@ -40,7 +40,7 @@ const
iterator instantiateGenericParamList(c: PContext, n: PNode, pt: TIdTable): PSym =
internalAssert c.config, n.kind == nkGenericParams
for i, a in n.pairs:
for a in n.items:
internalAssert c.config, a.kind == nkSym
var q = a.sym
if q.typ.kind in {tyTypeDesc, tyGenericParam, tyStatic, tyConcept}+tyTypeClasses: