compiler: optimize parse_lib_imports (#2319)

* optimize parse_lib_imports
* comment unused import
pull/2320/head
joe-conigliaro 2019-10-13 15:11:40 +11:00 committed by GitHub
parent 039dafb30f
commit 8e90724684
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

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

View File

@ -4,7 +4,7 @@ import gx
import gg
import time
import glfw
import math
// import math
import os
const (