about summary refs log tree commit diff
path: root/src/liballoc/rc.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-06-30 03:46:25 +0000
committerbors <bors@rust-lang.org>2014-06-30 03:46:25 +0000
commite25eb6b223d86047dc807a167f3dd4bf492bbf41 (patch)
treeb0c22f04747ee2122e32e8c101e371be5fca01c8 /src/liballoc/rc.rs
parent9ae48286a99627391e30da3888217e6050230cfe (diff)
parentab1bd3adf673ef7a515242a2dcc09ce360d41d9c (diff)
downloadrust-e25eb6b223d86047dc807a167f3dd4bf492bbf41.tar.gz
rust-e25eb6b223d86047dc807a167f3dd4bf492bbf41.zip
auto merge of #15256 : erickt/rust/optimizations, r=alexcrichton
The bug #11084 causes `option::collect` and `result::collect` about twice as slower as it should because llvm is having some trouble optimizing away the scan closure. This gets rid of it so now those functions perform equivalent to a hand written version.

This also adds an impl of `Default` for `Rc` along the way.
Diffstat (limited to 'src/liballoc/rc.rs')
-rw-r--r--src/liballoc/rc.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index a3ca72f1547..e3127030842 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -27,6 +27,7 @@ use core::mem::transmute;
 use core::cell::Cell;
 use core::clone::Clone;
 use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
+use core::default::Default;
 use core::kinds::marker;
 use core::ops::{Deref, Drop};
 use core::option::{Option, Some, None};
@@ -152,6 +153,13 @@ impl<T> Clone for Rc<T> {
     }
 }
 
+impl<T: Default> Default for Rc<T> {
+    #[inline]
+    fn default() -> Rc<T> {
+        Rc::new(Default::default())
+    }
+}
+
 impl<T: PartialEq> PartialEq for Rc<T> {
     #[inline(always)]
     fn eq(&self, other: &Rc<T>) -> bool { **self == **other }