From 775d399da84776bfd8ae09af5f402874372e299c Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Fri, 4 Nov 2016 18:47:32 +0000 Subject: [PATCH] Remove recursive call from Cow::to_mut It seems to prevent it from being inlined. --- src/libcollections/borrow.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcollections/borrow.rs b/src/libcollections/borrow.rs index 8f9c357833791..30286fb243c1d 100644 --- a/src/libcollections/borrow.rs +++ b/src/libcollections/borrow.rs @@ -159,7 +159,10 @@ impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned { match *self { Borrowed(borrowed) => { *self = Owned(borrowed.to_owned()); - self.to_mut() + match *self { + Borrowed(..) => unreachable!(), + Owned(ref mut owned) => owned, + } } Owned(ref mut owned) => owned, }