rename expand to inline
This commit is contained in:
+2
-2
@@ -17,7 +17,7 @@ init func(
|
||||
map EnumMap(E, V) = undefined
|
||||
|
||||
match typeinfo!(E) {
|
||||
.enum |info|: expand for info.fields |field, i| {
|
||||
.enum |info|: inline for info.fields |field, i| {
|
||||
map.present[i] = false
|
||||
|
||||
if field!(values, field.name) |value| {
|
||||
@@ -34,7 +34,7 @@ init func(
|
||||
get func($E, $V type, map @EnumMap(E, V), key E) ?V {
|
||||
# fixme: linear lookup; implement an enum index/discriminant map for O(1) lookup
|
||||
match typeinfo!(E) {
|
||||
.enum |info|: expand for info.fields |field, i| {
|
||||
.enum |info|: inline for info.fields |field, i| {
|
||||
if key == field!(E, field.name) {
|
||||
if (map.present[i]) return map.values[i]
|
||||
return null
|
||||
|
||||
+2
-2
@@ -111,7 +111,7 @@ stderr func(io Io) Writer {
|
||||
}
|
||||
|
||||
print func(output Writer, $format []u8, $Args type, args Args) void ! WriteError {
|
||||
expand for parse_format(format.len, format, Args) |token| {
|
||||
inline for parse_format(format.len, format, Args) |token| {
|
||||
match token.kind {
|
||||
.unused: break
|
||||
.literal: try write_all(output, format[token.start..token.end])
|
||||
@@ -427,7 +427,7 @@ hide write_default func(output Writer, $T type, value T) void ! WriteError {
|
||||
.pointer: try write_all(output, value)
|
||||
.slice: try write_all(output, value)
|
||||
.enum |enum_info|: {
|
||||
expand for enum_info.fields |field| {
|
||||
inline for enum_info.fields |field| {
|
||||
if value == field!(T, field.name) {
|
||||
try write_all(output, ".")
|
||||
try write_all(output, field.name)
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ EnumFieldStruct func($E, $Field type, $default ?Field) type {
|
||||
names [info.fields.len]mut []u8 = undefined
|
||||
field_types [info.fields.len]mut type = undefined
|
||||
defaults [info.fields.len]mut ?Field = undefined
|
||||
expand for info.fields |field, index| {
|
||||
inline for info.fields |field, index| {
|
||||
names[index] = field.name
|
||||
field_types[index] = Field
|
||||
defaults[index] = default
|
||||
|
||||
Reference in New Issue
Block a user