mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
stage1: hot path for resolving types of primitives
This is an attempt to save memory when building self-hosted. before: Total bytes allocated: 5.941 GiB, deallocated: 2.259 GiB, remaining: 3.681 GiB after: Total bytes allocated: 5.933 GiB, deallocated: 2.253 GiB, remaining: 3.680 GiB
This commit is contained in:
parent
0965724e31
commit
c37f273cb0
@ -1490,6 +1490,20 @@ static OnePossibleValue type_val_resolve_has_one_possible_value(CodeGen *g, ZigV
|
|||||||
}
|
}
|
||||||
|
|
||||||
ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node) {
|
ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node) {
|
||||||
|
Error err;
|
||||||
|
// Hot path for simple identifiers, to avoid unnecessary memory allocations.
|
||||||
|
if (node->type == NodeTypeSymbol) {
|
||||||
|
Buf *variable_name = node->data.symbol_expr.symbol;
|
||||||
|
if (buf_eql_str(variable_name, "_"))
|
||||||
|
goto abort_hot_path;
|
||||||
|
ZigType *primitive_type;
|
||||||
|
if ((err = get_primitive_type(g, variable_name, &primitive_type))) {
|
||||||
|
goto abort_hot_path;
|
||||||
|
} else {
|
||||||
|
return primitive_type;
|
||||||
|
}
|
||||||
|
abort_hot_path:;
|
||||||
|
}
|
||||||
ZigValue *result = analyze_const_value(g, scope, node, g->builtin_types.entry_type,
|
ZigValue *result = analyze_const_value(g, scope, node, g->builtin_types.entry_type,
|
||||||
nullptr, UndefBad);
|
nullptr, UndefBad);
|
||||||
if (type_is_invalid(result->type))
|
if (type_is_invalid(result->type))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user