improve comment, fix typos

This commit is contained in:
Delyan Angelov 2025-08-23 08:26:14 +03:00
parent a6538757da
commit 31e46f3f6a
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED

View file

@ -379,7 +379,7 @@ fn (mut g Gen) gen_str_for_enum(info ast.Enum, styp string, str_fn_name string)
g.auto_str_funcs.writeln('\tret = string__plus(ret, _S("}"));') g.auto_str_funcs.writeln('\tret = string__plus(ret, _S("}"));')
g.auto_str_funcs.writeln('\treturn ret;') g.auto_str_funcs.writeln('\treturn ret;')
} else if info.uses_exprs { } else if info.uses_exprs {
// This enum values could be C macros, that are expanded later to duplicate values, so we can not use a switch here. // The enum values could be C macros, expanded later to duplicate values, and we do not know if that is the case, so we can not use a switch here.
// Instead we generate multiple if statements, which is slower, but is guaranteed to work in the presence of duplicates. // Instead we generate multiple if statements, which is slower, but is guaranteed to work in the presence of duplicates.
for val in info.vals { for val in info.vals {
g.auto_str_funcs.writeln('\t\tif(it == ${s}__${val}){ return _S("${val}"); }') g.auto_str_funcs.writeln('\t\tif(it == ${s}__${val}){ return _S("${val}"); }')