Skip to content

Commit ce23a99

Browse files
committed
libcore: Make a few more dvec functions inline. Improves profile of Servo. rs=me
1 parent b2d5acd commit ce23a99

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/libcore/dvec.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub fn unwrap<A>(d: DVec<A>) -> ~[A] {
7777
}
7878

7979
priv impl<A> DVec<A> {
80+
#[inline(always)]
8081
pure fn check_not_borrowed() {
8182
unsafe {
8283
let data: *() = cast::reinterpret_cast(&self.data);
@@ -137,17 +138,14 @@ impl<A> DVec<A> {
137138
}
138139

139140
/// Returns the number of elements currently in the dvec
141+
#[inline(always)]
140142
pure fn len() -> uint {
141-
unsafe {
142-
do self.check_out |v| {
143-
let l = v.len();
144-
self.give_back(move v);
145-
l
146-
}
147-
}
143+
self.check_not_borrowed();
144+
return self.data.len();
148145
}
149146

150147
/// Overwrite the current contents
148+
#[inline(always)]
151149
fn set(w: ~[A]) {
152150
self.check_not_borrowed();
153151
self.data = move w;
@@ -178,6 +176,7 @@ impl<A> DVec<A> {
178176
}
179177
180178
/// Append a single item to the end of the list
179+
#[inline(always)]
181180
fn push(t: A) {
182181
self.check_not_borrowed();
183182
self.data.push(move t);
@@ -354,6 +353,7 @@ impl<A: Copy> DVec<A> {
354353
}
355354

356355
impl<A:Copy> DVec<A>: Index<uint,A> {
356+
#[inline(always)]
357357
pure fn index(idx: uint) -> A {
358358
self.get_elt(idx)
359359
}

0 commit comments

Comments
 (0)