From 8e9072468478699f79593d3d89a76c4016175d13 Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Sun, 13 Oct 2019 15:11:40 +1100 Subject: [PATCH] compiler: optimize parse_lib_imports (#2319) * optimize parse_lib_imports * comment unused import --- compiler/main.v | 4 ++-- examples/hot_reload/graph.v | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/main.v b/compiler/main.v index 6c8a046a5f..57778c6d32 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -741,6 +741,7 @@ fn (v mut V) parse_lib_imports() { for _, fit in v.table.file_imports { if fit.file_path_id in done_fits { continue } for _, mod in fit.imports { + if mod in done_imports { continue } import_path := v.find_module_path(mod) or { pidx := v.get_file_parser_index(fit.file_path_id) or { verror(err) break } v.parsers[pidx].error_with_token_index('cannot import module "$mod" (not found)', fit.get_import_tok_idx(mod)) @@ -753,14 +754,13 @@ fn (v mut V) parse_lib_imports() { } // Add all imports referenced by these libs for file in vfiles { - if file in done_imports { continue } pid := v.parse(file, .imports) - done_imports << file p_mod := v.parsers[pid].import_table.module_name if p_mod != mod { v.parsers[pid].error_with_token_index('bad module definition: $fit.file_path_id imports module "$mod" but $file is defined as module `$p_mod`', 1) } } + done_imports << mod } done_fits << fit.file_path_id } diff --git a/examples/hot_reload/graph.v b/examples/hot_reload/graph.v index 7a4861ad49..79c9b08e59 100644 --- a/examples/hot_reload/graph.v +++ b/examples/hot_reload/graph.v @@ -4,7 +4,7 @@ import gx import gg import time import glfw -import math +// import math import os const (