mirror of
https://github.com/ziglang/zig.git
synced 2025-12-27 16:43:07 +00:00
InternPool: fix nameIndex for tuples
This commit is contained in:
parent
c79da0d731
commit
2671aa9058
@ -439,7 +439,11 @@ pub const Key = union(enum) {
|
||||
|
||||
/// Look up field index based on field name.
|
||||
pub fn nameIndex(self: StructType, ip: *const InternPool, name: NullTerminatedString) ?u32 {
|
||||
const names_map = self.names_map.unwrap() orelse return null;
|
||||
const names_map = self.names_map.unwrap() orelse {
|
||||
const i = name.toUnsigned(ip) orelse return null;
|
||||
if (i >= self.field_types.len) return null;
|
||||
return i;
|
||||
};
|
||||
const map = &ip.maps.items[@intFromEnum(names_map)];
|
||||
const adapter: NullTerminatedString.Adapter = .{ .strings = self.field_names.get(ip) };
|
||||
const field_index = map.getIndexAdapted(name, adapter) orelse return null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user