diff options
author | Kamal Marhubi <kamal@marhubi.com> | 2016-01-27 21:11:19 -0500 |
---|---|---|
committer | Kamal Marhubi <kamal@marhubi.com> | 2016-01-27 21:37:25 -0500 |
commit | 62809fb6f045a12af72c6a09516aa4afe55ab963 (patch) | |
tree | 81a24fb43249e469512d396024dfbeb25a281f1f /src/lib.rs | |
parent | d0881f63ec375b45a0b160a7017e4940b18edf4e (diff) | |
download | nix-62809fb6f045a12af72c6a09516aa4afe55ab963.zip |
Avoid stack allocation in with_nix_path for Option::None
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 4 |
1 files changed, 1 insertions, 3 deletions
@@ -220,9 +220,7 @@ impl<'a, NP: ?Sized + NixPath> NixPath for Option<&'a NP> { if let Some(nix_path) = *self { nix_path.with_nix_path(f) } else { - // TODO(#229): avoid extra stack allocation from [u8] impl by - // replacing with empty CStr. - b"".with_nix_path(f) + unsafe { CStr::from_ptr("\0".as_ptr() as *const _).with_nix_path(f) } } } } |