]> git.lizzy.rs Git - rust.git/commitdiff
Remove recursive call from Cow::to_mut
authorOliver Middleton <olliemail27@gmail.com>
Fri, 4 Nov 2016 18:47:32 +0000 (18:47 +0000)
committerOliver Middleton <olliemail27@gmail.com>
Fri, 4 Nov 2016 18:47:32 +0000 (18:47 +0000)
It seems to prevent it from being inlined.

src/libcollections/borrow.rs

index 8f9c35783379133e98a31bc58c9d1c086d0e936e..30286fb243c1d84c4328beaebf8ab4804fa8e657 100644 (file)
@@ -159,7 +159,10 @@ pub fn to_mut(&mut self) -> &mut <B as ToOwned>::Owned {
         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,
         }