Change memory layout of map to be 3 words smaller

This commit is contained in:
gingerBill
2018-08-30 19:14:10 +01:00
parent e0240c186f
commit aa542980ce
12 changed files with 114 additions and 44 deletions

View File

@@ -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;