Skip to content

Commit

Permalink
libcore: Make a few more dvec functions inline. Improves profile of S…
Browse files Browse the repository at this point in the history
…ervo. rs=me
  • Loading branch information
pcwalton committed Oct 25, 2012
1 parent b2d5acd commit ce23a99
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/libcore/dvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pub fn unwrap<A>(d: DVec<A>) -> ~[A] {
}

priv impl<A> DVec<A> {
#[inline(always)]
pure fn check_not_borrowed() {
unsafe {
let data: *() = cast::reinterpret_cast(&self.data);
Expand Down Expand Up @@ -137,17 +138,14 @@ impl<A> DVec<A> {
}

/// 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;
Expand Down Expand Up @@ -178,6 +176,7 @@ impl<A> DVec<A> {
}
/// 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);
Expand Down Expand Up @@ -354,6 +353,7 @@ impl<A: Copy> DVec<A> {
}

impl<A:Copy> DVec<A>: Index<uint,A> {
#[inline(always)]
pure fn index(idx: uint) -> A {
self.get_elt(idx)
}
Expand Down

0 comments on commit ce23a99

Please sign in to comment.