Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
1413: some minor improvements r=MarkMcCaskey a=michaelvoronov

<!-- 
Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test:
https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests

-->

# Description

Some minor improvements.

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: vms <[email protected]>
  • Loading branch information
bors[bot] and mikevoronov authored Apr 29, 2020
2 parents 0cba64b + c4fd02a commit f48a4d9
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/runtime-c-api/src/import/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 1 addition & 9 deletions lib/runtime-core/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime-core/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 3 additions & 5 deletions lib/wasi/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1979,12 +1979,10 @@ pub fn path_remove_directory(

let host_path_to_remove = match &state.fs.inodes[inode].kind {
Kind::Dir { entries, path, .. } => {
if !entries.is_empty() {
if !entries.is_empty()
|| 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()
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion tests/test-generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/wast/src/wast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f48a4d9

Please sign in to comment.