about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-02-28 13:26:30 -0800
committerbors <bors@rust-lang.org>2014-02-28 13:26:30 -0800
commit5b4a141b6adceeb82f5a2c97cdf55224fa56826e (patch)
treebc3e975c830c50d72ae5ac89c339a9ef43d70a2c /src/libstd/sync
parent84ebf74ee2f163461cf021b3d415171e8b5ef8be (diff)
parentddc1c21264898f6a5d12cf03bba30f1f08b73665 (diff)
downloadrust-5b4a141b6adceeb82f5a2c97cdf55224fa56826e.tar.gz
rust-5b4a141b6adceeb82f5a2c97cdf55224fa56826e.zip
auto merge of #12616 : alexcrichton/rust/size, r=huonw
I've been playing around with code size when linking to libstd recently, and these were some findings I found that really helped code size. I started out by eliminating all I/O implementations from libnative and instead just return an unimplemented error.

In doing so, a `fn main() {}` executable was ~378K before this patch, and about 170K after the patch. These size wins are all pretty minor, but they all seemed pretty reasonable to me. With native I/O not stubbed out, this takes the size of an LTO executable from 675K to 400K.
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/arc.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libstd/sync/arc.rs b/src/libstd/sync/arc.rs
index 5c452018b9b..10369a52f0f 100644
--- a/src/libstd/sync/arc.rs
+++ b/src/libstd/sync/arc.rs
@@ -80,7 +80,8 @@ impl<T: Send> UnsafeArc<T> {
     #[inline]
     pub fn get(&self) -> *mut T {
         unsafe {
-            assert!((*self.data).count.load(Relaxed) > 0);
+            // FIXME(#12049): this needs some sort of debug assertion
+            if cfg!(test) { assert!((*self.data).count.load(Relaxed) > 0); }
             return &mut (*self.data).data as *mut T;
         }
     }
@@ -90,7 +91,8 @@ impl<T: Send> UnsafeArc<T> {
     #[inline]
     pub fn get_immut(&self) -> *T {
         unsafe {
-            assert!((*self.data).count.load(Relaxed) > 0);
+            // FIXME(#12049): this needs some sort of debug assertion
+            if cfg!(test) { assert!((*self.data).count.load(Relaxed) > 0); }
             return &(*self.data).data as *T;
         }
     }
@@ -109,7 +111,8 @@ impl<T: Send> Clone for UnsafeArc<T> {
         unsafe {
             // This barrier might be unnecessary, but I'm not sure...
             let old_count = (*self.data).count.fetch_add(1, Acquire);
-            assert!(old_count >= 1);
+            // FIXME(#12049): this needs some sort of debug assertion
+            if cfg!(test) { assert!(old_count >= 1); }
             return UnsafeArc { data: self.data };
         }
     }
@@ -127,7 +130,8 @@ impl<T> Drop for UnsafeArc<T>{
             // Must be acquire+release, not just release, to make sure this
             // doesn't get reordered to after the unwrapper pointer load.
             let old_count = (*self.data).count.fetch_sub(1, SeqCst);
-            assert!(old_count >= 1);
+            // FIXME(#12049): this needs some sort of debug assertion
+            if cfg!(test) { assert!(old_count >= 1); }
             if old_count == 1 {
                 let _: ~ArcData<T> = cast::transmute(self.data);
             }