Skip to content

Commit

Permalink
perform: Parser performance optimization: remove duplicate dependency…
Browse files Browse the repository at this point in the history
… analysis

Signed-off-by: he1pa <[email protected]>
  • Loading branch information
He1pa committed Oct 23, 2024
1 parent fc64537 commit d79d9a1
Showing 1 changed file with 10 additions and 29 deletions.
39 changes: 10 additions & 29 deletions kclvm/parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,19 +816,7 @@ pub fn parse_entry(
let module_cache_read = module_cache.read();
match &module_cache_read {
Ok(m_cache) => match m_cache.ast_cache.get(&file.canonicalize()) {
Some(m) => {
let deps = get_deps(&file, m.as_ref(), pkgs, pkgmap, opts, sess.clone())?;
match &mut file_graph.write() {
Ok(file_graph) => {
file_graph.update_file(&file, &deps);
if file_graph.toposort().is_ok() {
unparsed_file.extend(deps);
}
continue;
}
Err(e) => return Err(anyhow::anyhow!("Parse entry failed: {e}")),
}
}
Some(_) => continue,
None => {
drop(module_cache_read);
let deps = parse_file(
Expand Down Expand Up @@ -921,27 +909,20 @@ pub fn parse_program(
};

let pkg = pkgmap.get(file).expect("file not in pkgmap");
fix_rel_import_path_with_file(
&pkg.pkg_root,
&mut m,
file,
&pkgmap,
opts.clone(),
sess.clone(),
);

match pkgs.get_mut(&file.pkg_path) {
Some(modules) => {
fix_rel_import_path_with_file(
&pkg.pkg_root,
&mut m,
file,
&pkgmap,
opts.clone(),
sess.clone(),
);
modules.push(m);
}
None => {
fix_rel_import_path_with_file(
&pkg.pkg_root,
&mut m,
file,
&pkgmap,
opts.clone(),
sess.clone(),
);
pkgs.insert(file.pkg_path.clone(), vec![m]);
}
}
Expand Down

0 comments on commit d79d9a1

Please sign in to comment.