From ce23a9992542f0c82e0f32c427b572caae790754 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 25 Oct 2012 10:21:34 -0700 Subject: [PATCH] libcore: Make a few more dvec functions inline. Improves profile of Servo. rs=me --- src/libcore/dvec.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index e01e3fea3e175..647f2f052cacc 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -77,6 +77,7 @@ pub fn unwrap(d: DVec) -> ~[A] { } priv impl DVec { + #[inline(always)] pure fn check_not_borrowed() { unsafe { let data: *() = cast::reinterpret_cast(&self.data); @@ -137,17 +138,14 @@ impl DVec { } /// Returns the number of elements currently in the dvec + #[inline(always)] pure fn len() -> uint { - unsafe { - do self.check_out |v| { - let l = v.len(); - self.give_back(move v); - l - } - } + self.check_not_borrowed(); + return self.data.len(); } /// Overwrite the current contents + #[inline(always)] fn set(w: ~[A]) { self.check_not_borrowed(); self.data = move w; @@ -178,6 +176,7 @@ impl DVec { } /// Append a single item to the end of the list + #[inline(always)] fn push(t: A) { self.check_not_borrowed(); self.data.push(move t); @@ -354,6 +353,7 @@ impl DVec { } impl DVec: Index { + #[inline(always)] pure fn index(idx: uint) -> A { self.get_elt(idx) }