From 28467f5d197d1455e922711a28ea4a19702dbda9 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Fri, 7 Feb 2014 14:58:37 -0800 Subject: Tweak from_utf8_lossy to return a new MaybeOwned enum MaybeOwned allows from_utf8_lossy to avoid allocation if there are no invalid bytes in the input. --- src/libstd/path/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libstd/path') diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index 18f28994cba..d5a69b12f2a 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -508,10 +508,10 @@ impl<'a, P: GenericPath> ToStr for Display<'a, P> { if self.filename { match self.path.filename() { None => ~"", - Some(v) => str::from_utf8_lossy(v) + Some(v) => str::from_utf8_lossy(v).into_owned() } } else { - str::from_utf8_lossy(self.path.as_vec()) + str::from_utf8_lossy(self.path.as_vec()).into_owned() } } } -- cgit 1.4.1-3-g733a5