From d63885a495d2314a5ef76337605a9ebeefb26218 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 25 Feb 2018 19:23:52 +0000 Subject: `array_make` --- src/types.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/types.cpp') diff --git a/src/types.cpp b/src/types.cpp index 1f9724578..95b13d78f 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -1522,8 +1522,7 @@ Selection lookup_field_from_index(gbAllocator a, Type *type, i64 index) { Entity *f = type->Struct.fields[i]; if (f->kind == Entity_Variable) { if (f->Variable.field_src_index == index) { - Array sel_array = {0}; - array_init_count(&sel_array, a, 1); + auto sel_array = array_make(a, 1); sel_array[0] = cast(i32)i; return make_selection(f, sel_array, false); } @@ -1534,8 +1533,7 @@ Selection lookup_field_from_index(gbAllocator a, Type *type, i64 index) { for (isize i = 0; i < max_count; i++) { Entity *f = type->Tuple.variables[i]; if (i == index) { - Array sel_array = {0}; - array_init_count(&sel_array, a, 1); + auto sel_array = array_make(a, 1); sel_array[0] = cast(i32)i; return make_selection(f, sel_array, false); } @@ -1543,8 +1541,7 @@ Selection lookup_field_from_index(gbAllocator a, Type *type, i64 index) { break; case Type_BitField: { - Array sel_array = {0}; - array_init_count(&sel_array, a, 1); + auto sel_array = array_make(a, 1); sel_array[0] = cast(i32)index; return make_selection(type->BitField.fields[index], sel_array, false); } break; @@ -1979,8 +1976,7 @@ i64 type_align_of_internal(gbAllocator allocator, Type *t, TypePath *path) { } Array type_set_offsets_of(gbAllocator allocator, Array fields, bool is_packed, bool is_raw_union) { - Array offsets = {}; - array_init_count(&offsets, allocator, fields.count); + auto offsets = array_make(allocator, fields.count); i64 curr_offset = 0; if (is_raw_union) { for_array(i, fields) { -- cgit v1.2.3