From 2ee08098a6315aaab07f14c67db024ee0e95af3e Mon Sep 17 00:00:00 2001
From: Aleksey Kladov <aleksey.kladov@gmail.com>
Date: Mon, 28 Jan 2019 15:52:21 +0300
Subject: opt-in jemalloc

---
 crates/ra_ide_api/src/lib.rs    | 1 +
 crates/ra_ide_api/src/status.rs | 9 +++++++++
 2 files changed, 10 insertions(+)

(limited to 'crates/ra_ide_api/src')

diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index dc531e068..51947e4cc 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -61,6 +61,7 @@ pub use ra_db::{
 
 // We use jemalloc mainly to get heap usage statistics, actual performance
 // differnece is not measures.
+#[cfg(feature = "jemalloc")]
 #[global_allocator]
 static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
 
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs
index c3e5745d5..bd355dd78 100644
--- a/crates/ra_ide_api/src/status.rs
+++ b/crates/ra_ide_api/src/status.rs
@@ -133,6 +133,7 @@ struct MemoryStats {
 }
 
 impl MemoryStats {
+    #[cfg(feature = "jemalloc")]
     fn current() -> MemoryStats {
         jemalloc_ctl::epoch().unwrap();
         MemoryStats {
@@ -140,6 +141,14 @@ impl MemoryStats {
             resident: Bytes(jemalloc_ctl::stats::resident().unwrap()),
         }
     }
+
+    #[cfg(not(feature = "jemalloc"))]
+    fn current() -> MemoryStats {
+        MemoryStats {
+            allocated: Bytes(0),
+            resident: Bytes(0),
+        }
+    }
 }
 
 impl fmt::Display for MemoryStats {
-- 
cgit v1.2.3