summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorKamal Marhubi <kamal@marhubi.com>2016-01-27 21:11:19 -0500
committerKamal Marhubi <kamal@marhubi.com>2016-01-27 21:37:25 -0500
commit62809fb6f045a12af72c6a09516aa4afe55ab963 (patch)
tree81a24fb43249e469512d396024dfbeb25a281f1f /src/lib.rs
parentd0881f63ec375b45a0b160a7017e4940b18edf4e (diff)
downloadnix-62809fb6f045a12af72c6a09516aa4afe55ab963.zip
Avoid stack allocation in with_nix_path for Option::None
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 94f15799..0de90494 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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) }
}
}
}