From d63885a495d2314a5ef76337605a9ebeefb26218 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 25 Feb 2018 19:23:52 +0000 Subject: `array_make` --- src/checker.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/checker.cpp') diff --git a/src/checker.cpp b/src/checker.cpp index 3a11d4f94..5943ae71d 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -645,7 +645,7 @@ void init_checker(Checker *c, Parser *parser) { map_init(&c->file_scopes, heap_allocator()); ptr_set_init(&c->checked_files, heap_allocator()); - array_init(&c->file_order, heap_allocator(), c->parser->files.count); + array_init(&c->file_order, heap_allocator(), 0, c->parser->files.count); } void destroy_checker(Checker *c) { @@ -1219,8 +1219,7 @@ Array generate_entity_dependency_graph(CheckerInfo *info) { } } - Array G = {}; - array_init(&G, a, M.entries.count); + auto G = array_make(a, 0, M.entries.count); for_array(i, M.entries) { auto *entry = &M.entries[i]; @@ -2247,12 +2246,11 @@ Array find_import_path(Checker *c, Scope *start, Scope *end, Ptr ImportPathItem item = {s, decl}; if (s == end) { - Array path = {}; - array_init(&path, heap_allocator()); + auto path = array_make(heap_allocator()); array_add(&path, item); return path; } - Array next_path = find_import_path(c, s, end, visited); + auto next_path = find_import_path(c, s, end, visited); if (next_path.count > 0) { array_add(&next_path, item); return next_path; @@ -2853,12 +2851,11 @@ Array find_entity_path(Entity *start, Entity *end, Map *visi for_array(i, decl->deps.entries) { Entity *dep = decl->deps.entries[i].ptr; if (dep == end) { - Array path = {}; - array_init(&path, heap_allocator()); + auto path = array_make(heap_allocator()); array_add(&path, dep); return path; } - Array next_path = find_entity_path(dep, end, visited); + auto next_path = find_entity_path(dep, end, visited); if (next_path.count > 0) { array_add(&next_path, dep); return next_path; -- cgit v1.2.3