| ... | @@ -7975,8 +7975,14 @@ fn callExpr( | ... | @@ -7975,8 +7975,14 @@ fn callExpr( |
| 7975 | | 7975 | |
| 7976 | const callee = try calleeExpr(gz, scope, call.ast.fn_expr); | 7976 | const callee = try calleeExpr(gz, scope, call.ast.fn_expr); |
| 7977 | | 7977 | |
| 7978 | const args = try astgen.gpa.alloc(Zir.Inst.Ref, call.ast.params.len); | 7978 | // A large proportion of calls have 5 or less arguments, due to this preventing allocations |
| 7979 | defer astgen.gpa.free(args); | 7979 | // for calls with few arguments has a sizeable effect on the aggregated runtime of this function |
| | 7980 | var arg_buffer: [5]Zir.Inst.Ref = undefined; |
| | 7981 | const args: []Zir.Inst.Ref = if (call.ast.params.len <= arg_buffer.len) |
| | 7982 | arg_buffer[0..call.ast.params.len] |
| | 7983 | else |
| | 7984 | try astgen.gpa.alloc(Zir.Inst.Ref, call.ast.params.len); |
| | 7985 | defer if (call.ast.params.len > arg_buffer.len) astgen.gpa.free(args); |
| 7980 | | 7986 | |
| 7981 | for (call.ast.params) |param_node, i| { | 7987 | for (call.ast.params) |param_node, i| { |
| 7982 | // Parameters are always temporary values, they have no | 7988 | // Parameters are always temporary values, they have no |