Skip to content

Commit

Permalink
Remove redundant checking of promise resolve and clone of URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
CYBAI committed Jan 6, 2020
1 parent 9460b43 commit b8c6b55
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions components/script/script_module.rs
Expand Up @@ -1143,18 +1143,14 @@ pub fn fetch_single_module_script(
let global = owner.global();
let module_map = global.get_module_map().borrow();

debug!("Start to fetch {}", url.clone());
debug!("Start to fetch {}", url);

if let Some(module_tree) = module_map.get(&url.clone()) {
let status = module_tree.get_status();

let promise = module_tree.get_promise().borrow();

debug!(
"Meet a fetched url {} and its status is {:?}",
url.clone(),
status
);
debug!("Meet a fetched url {} and its status is {:?}", url, status);

assert!(promise.is_some());

Expand All @@ -1170,24 +1166,12 @@ pub fn fetch_single_module_script(
ModuleStatus::Fetching => return promise.clone(),
ModuleStatus::FetchingDescendants => {
if module_tree.has_all_ready_descendants(&module_map) {
let module_error = module_tree.get_error().borrow();

if module_error.is_some() {
promise.resolve_native(&());
} else {
promise.resolve_native(&());
}
promise.resolve_native(&());
}
},
// Step 3.
ModuleStatus::FetchFailed | ModuleStatus::Ready | ModuleStatus::Finished => {
let module_error = module_tree.get_error().borrow();

if module_error.is_some() {
promise.resolve_native(&());
} else {
promise.resolve_native(&());
}
promise.resolve_native(&());
},
}

Expand Down

0 comments on commit b8c6b55

Please sign in to comment.