diff options
| author | gingerBill <bill@gingerbill.org> | 2018-08-30 19:14:10 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-08-30 19:14:10 +0100 |
| commit | aa542980cea146e05cf9bb5f1d792e1f092328ae (patch) | |
| tree | eea45538d6934f0c669a5bf218396d2ce6294098 /src/types.cpp | |
| parent | e0240c186f2939f39f2051c5123b8b75e5fdb184 (diff) | |
Change memory layout of `map` to be 3 words smaller
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
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; |