some minor improvements

This commit is contained in:
vms 2020-04-29 23:15:38 +03:00
parent 0cba64b538
commit abed2c238a
7 changed files with 8 additions and 18 deletions

View File

@ -206,7 +206,7 @@ pub unsafe extern "C" fn wasmer_import_object_iterate_functions(
return std::ptr::null_mut();
}
let import_object: &ImportObject = &*(import_object as *const ImportObject);
let iter_inner = Box::new(import_object.clone_ref().into_iter().filter(|(_, _, e)| {
let iter_inner = Box::new(import_object.clone().into_iter().filter(|(_, _, e)| {
if let Export::Function { .. } = e {
true
} else {

View File

@ -54,6 +54,7 @@ impl IsExport for Export {
/// n
/// }
/// ```
#[derive(Clone)]
pub struct ImportObject {
map: Arc<Mutex<HashMap<String, Box<dyn LikeNamespace + Send>>>>,
pub(crate) state_creator:
@ -158,15 +159,6 @@ impl ImportObject {
.and_then(|ns| f(ns))
}
/// Create a clone ref of this namespace.
pub fn clone_ref(&self) -> Self {
Self {
map: Arc::clone(&self.map),
state_creator: self.state_creator.clone(),
allow_missing_functions: false,
}
}
fn get_objects(&self) -> VecDeque<(String, String, Export)> {
let mut out = VecDeque::new();
let guard = self.map.lock().unwrap();

View File

@ -103,7 +103,7 @@ impl Instance {
module,
inner,
exports,
import_object: imports.clone_ref(),
import_object: imports.clone(),
};
if let Some(start_index) = instance.module.info.start_func {

View File

@ -1981,10 +1981,8 @@ pub fn path_remove_directory(
Kind::Dir { entries, path, .. } => {
if !entries.is_empty() {
return __WASI_ENOTEMPTY;
} else {
if wasi_try!(std::fs::read_dir(path).ok(), __WASI_EIO).count() != 0 {
return __WASI_ENOTEMPTY;
}
} else if wasi_try!(std::fs::read_dir(path).ok(), __WASI_EIO).count() != 0 {
return __WASI_ENOTEMPTY;
}
path.clone()
}

View File

@ -21,7 +21,7 @@ impl Cache {
if cache_dir.exists() {
fs::remove_dir_all(cache_dir.clone()).expect("Can't remove cache dir");
}
fs::create_dir_all(cache_dir.clone()).expect("Can't create cache dir");
fs::create_dir_all(cache_dir).expect("Can't create cache dir");
}
Cache::Dir => {
println!("{}", get_cache_dir().to_string_lossy());

View File

@ -70,7 +70,7 @@ pub fn build_ignores_from_textfile(path: PathBuf) -> anyhow::Result<Ignores> {
} else {
(line, None)
};
if line.len() == 0 {
if line.is_empty() {
continue;
}

View File

@ -292,7 +292,7 @@ impl Wast {
let compiler = compiler_for_backend(self.backend).expect("backend not found");
let module = compile_with_config_with(module, config, &*compiler)?;
let mut imports = self.import_object.clone_ref();
let mut imports = self.import_object.clone();
for import in module.imports() {
let module_name = import.namespace;