mirror of
https://github.com/openharmony/third_party_rust_libloading.git
synced 2026-07-21 00:26:36 -04:00
Avoid reallocation in Windows filename building
Thanks @retep998
This commit is contained in:
@@ -26,9 +26,7 @@ impl Library {
|
||||
/// Corresponds to `LoadLibraryW(filename)`.
|
||||
#[inline]
|
||||
pub fn new<P: AsRef<OsStr>>(filename: P) -> ::Result<Library> {
|
||||
let mut wide_filename: Vec<u16> = filename.as_ref().encode_wide().collect();
|
||||
wide_filename.push(0);
|
||||
wide_filename.shrink_to_fit();
|
||||
let mut wide_filename: Vec<u16> = filename.as_ref().encode_wide().chain(Some(0)).collect();
|
||||
let _guard = ErrorModeGuard::new();
|
||||
|
||||
let ret = with_get_last_error(|| {
|
||||
|
||||
Reference in New Issue
Block a user