From: Elias Rohrer Date: Fri, 8 Sep 2023 07:40:45 +0000 (+0200) Subject: Have `path_to_windows_str` take reference to avoid `clone`s X-Git-Tag: v0.0.117-alpha1~19^2~1 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=9abe4bb23da245228abdde85e773837897bcb0ba;p=rust-lightning Have `path_to_windows_str` take reference to avoid `clone`s --- diff --git a/lightning-persister/src/fs_store.rs b/lightning-persister/src/fs_store.rs index 56d071da9..81f9709c4 100644 --- a/lightning-persister/src/fs_store.rs +++ b/lightning-persister/src/fs_store.rs @@ -26,7 +26,7 @@ macro_rules! call { } #[cfg(target_os = "windows")] -fn path_to_windows_str>(path: T) -> Vec { +fn path_to_windows_str>(path: &T) -> Vec { path.as_ref().encode_wide().chain(Some(0)).collect() } @@ -164,8 +164,8 @@ impl KVStore for FilesystemStore { let res = if dest_file_path.exists() { call!(unsafe { windows_sys::Win32::Storage::FileSystem::ReplaceFileW( - path_to_windows_str(dest_file_path.clone()).as_ptr(), - path_to_windows_str(tmp_file_path).as_ptr(), + path_to_windows_str(&dest_file_path).as_ptr(), + path_to_windows_str(&tmp_file_path).as_ptr(), std::ptr::null(), windows_sys::Win32::Storage::FileSystem::REPLACEFILE_IGNORE_MERGE_ERRORS, std::ptr::null_mut() as *const core::ffi::c_void, @@ -175,8 +175,8 @@ impl KVStore for FilesystemStore { } else { call!(unsafe { windows_sys::Win32::Storage::FileSystem::MoveFileExW( - path_to_windows_str(tmp_file_path).as_ptr(), - path_to_windows_str(dest_file_path.clone()).as_ptr(), + path_to_windows_str(&tmp_file_path).as_ptr(), + path_to_windows_str(&dest_file_path).as_ptr(), windows_sys::Win32::Storage::FileSystem::MOVEFILE_WRITE_THROUGH | windows_sys::Win32::Storage::FileSystem::MOVEFILE_REPLACE_EXISTING, ) @@ -263,8 +263,8 @@ impl KVStore for FilesystemStore { call!(unsafe { windows_sys::Win32::Storage::FileSystem::MoveFileExW( - path_to_windows_str(dest_file_path).as_ptr(), - path_to_windows_str(trash_file_path.clone()).as_ptr(), + path_to_windows_str(&dest_file_path).as_ptr(), + path_to_windows_str(&trash_file_path).as_ptr(), windows_sys::Win32::Storage::FileSystem::MOVEFILE_WRITE_THROUGH | windows_sys::Win32::Storage::FileSystem::MOVEFILE_REPLACE_EXISTING, )