summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2022-11-06 11:46:19 +0100
committerGitHub <noreply@github.com>2022-11-06 11:46:19 +0100
commit3c2c728eb62f7fea19ace6ee8caf2b8ad6d7dd72 (patch)
treeac9bb060819b3fda2bb5202fa5be24f7962bbee1 /compiler
parentf0400eef6830d02d4e3d58f930bf95260b5e485f (diff)
downloadNim-3c2c728eb62f7fea19ace6ee8caf2b8ad6d7dd72.tar.gz
codegen: optimized generation of proc headers (#20770)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ccgtypes.nim13
1 files changed, 6 insertions, 7 deletions
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index 1aa8292bd..72c8d4896 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -425,7 +425,7 @@ proc paramStorageLoc(param: PSym): TStorageLoc =
 proc genProcParams(m: BModule, t: PType, rettype, params: var Rope,
                    check: var IntSet, declareEnvironment=true;
                    weakDep=false) =
-  params = ""
+  params = "("
   if t[0] == nil or isInvalidReturnType(m.config, t):
     rettype = "void"
   else:
@@ -434,7 +434,7 @@ proc genProcParams(m: BModule, t: PType, rettype, params: var Rope,
     if t.n[i].kind != nkSym: internalError(m.config, t.n.info, "genProcParams")
     var param = t.n[i].sym
     if isCompileTimeOnly(param.typ): continue
-    if params != "": params.add(", ")
+    if params != "(": params.add(", ")
     fillParamName(m, param)
     fillLoc(param.loc, locParam, t.n[i],
             param.paramStorageLoc)
@@ -464,7 +464,7 @@ proc genProcParams(m: BModule, t: PType, rettype, params: var Rope,
       arr = arr[0].skipTypes({tySink})
   if t[0] != nil and isInvalidReturnType(m.config, t):
     var arr = t[0]
-    if params != "": params.add(", ")
+    if params != "(": params.add(", ")
     if mapReturnType(m.config, t[0]) != ctArray:
       if isHeaderFile in m.flags:
         # still generates types for `--header`
@@ -477,14 +477,13 @@ proc genProcParams(m: BModule, t: PType, rettype, params: var Rope,
       params.add(getTypeDescAux(m, arr, check, skResult))
     params.addf(" Result", [])
   if t.callConv == ccClosure and declareEnvironment:
-    if params != "": params.add(", ")
+    if params != "(": params.add(", ")
     params.add("void* ClE_0")
   if tfVarargs in t.flags:
-    if params != "": params.add(", ")
+    if params != "(": params.add(", ")
     params.add("...")
-  if params == "": params.add("void)")
+  if params == "(": params.add("void)")
   else: params.add(")")
-  params = "(" & params
 
 proc mangleRecFieldName(m: BModule; field: PSym): Rope =
   if {sfImportc, sfExportc} * field.flags != {}: