compiler: optimize, don't rescan module directory for files (#2334)

* optimize, don't rescan module directory for files
* move from table to v
pull/2336/head
joe-conigliaro 2019-10-14 12:07:59 +11:00 committed by GitHub
parent 6a951751f7
commit e5b0478e19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 4 deletions

View File

@ -574,7 +574,6 @@ pub fn (v mut V) add_v_files_to_compile() {
// main files will get added last
continue
}
// use cached built module if exists
if v.pref.build_mode != .build_module && !mod.contains('vweb') {
mod_path := mod.replace('.', os.path_separator)
@ -587,8 +586,7 @@ pub fn (v mut V) add_v_files_to_compile() {
}
}
// standard module
mod_path := v.find_module_path(mod) or { verror(err) break }
vfiles := v.v_files_from_dir(mod_path)
vfiles := v.get_imported_module_files(mod)
for file in vfiles {
v.files << file
}
@ -633,7 +631,7 @@ pub fn (v &V) get_user_files() []string {
if dir.ends_with('.v') {
// Just compile one file and get parent dir
user_files << dir
dir = dir.all_before('${os.path_separator}')
dir = dir.all_before(os.path_separator)
}
else {
// Add .v files from the directory being compiled
@ -653,6 +651,17 @@ pub fn (v &V) get_user_files() []string {
return user_files
}
// get module files from already parsed imports
fn (v &V) get_imported_module_files(mod string) []string {
mut files := []string
for _, fit in v.table.file_imports {
if fit.module_name == mod {
files << fit.file_path_id
}
}
return files
}
// parse deps from already parsed builtin/user files
pub fn (v mut V) parse_lib_imports() {
mut done_fits := []string