From aa542980cea146e05cf9bb5f1d792e1f092328ae Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 30 Aug 2018 19:14:10 +0100 Subject: Change memory layout of `map` to be 3 words smaller --- src/types.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/types.cpp') diff --git a/src/types.cpp b/src/types.cpp index 4b3ce2edd..62db34a60 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -1839,13 +1839,26 @@ Selection lookup_field_with_selection(Type *type_, String field_name, bool is_ty // `Raw_Dynamic_Array` type? GB_ASSERT(t_allocator != nullptr); String allocator_str = str_lit("allocator"); - gb_local_persist Entity *entity__allocator = alloc_entity_field(nullptr, make_token_ident(allocator_str), t_allocator, false, 0); + gb_local_persist Entity *entity__allocator = alloc_entity_field(nullptr, make_token_ident(allocator_str), t_allocator, false, 3); if (field_name == allocator_str) { selection_add_index(&sel, 3); sel.entity = entity__allocator; return sel; } + } else if (type->kind == Type_Map) { + // IMPORTANT TODO(bill): Should these members be available to should I only allow them with + // `Raw_Map` type? + GB_ASSERT(t_allocator != nullptr); + String allocator_str = str_lit("allocator"); + gb_local_persist Entity *entity__allocator = alloc_entity_field(nullptr, make_token_ident(allocator_str), t_allocator, false, 3); + + if (field_name == allocator_str) { + selection_add_index(&sel, 1); + selection_add_index(&sel, 3); + sel.entity = entity__allocator; + return sel; + } } return sel; -- cgit v1.2.3