From df05b59df72df1bf25467c99f47097f17eac5f46 Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Mon, 9 Nov 2015 23:00:03 +0200 Subject: [PATCH] Avoid reallocation in Windows filename building Thanks @retep998 --- src/os/windows/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/os/windows/mod.rs b/src/os/windows/mod.rs index 9d1d985..be28e26 100644 --- a/src/os/windows/mod.rs +++ b/src/os/windows/mod.rs @@ -26,9 +26,7 @@ impl Library { /// Corresponds to `LoadLibraryW(filename)`. #[inline] pub fn new>(filename: P) -> ::Result { - let mut wide_filename: Vec = filename.as_ref().encode_wide().collect(); - wide_filename.push(0); - wide_filename.shrink_to_fit(); + let mut wide_filename: Vec = filename.as_ref().encode_wide().chain(Some(0)).collect(); let _guard = ErrorModeGuard::new(); let ret = with_get_last_error(|| {