Skip to content

Commit c2f28e2

Browse files
committed
stdlib: Remove the now-obsolete vec::alloc_len in favor of vec::capacity
1 parent 8774493 commit c2f28e2

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/libcore/vec.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export reserve;
1111
export reserve_at_least;
1212
export capacity;
1313
export len;
14-
export alloc_len;
1514
export from_fn;
1615
export from_elem;
1716
export to_mut;
@@ -142,6 +141,7 @@ fn reserve_at_least<T>(&v: [const T], n: uint) {
142141
#[doc = "
143142
Returns the number of elements the vector can hold without reallocating
144143
"]
144+
#[inline(always)]
145145
fn capacity<T>(&&v: [const T]) -> uint unsafe {
146146
let repr: **unsafe::vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
147147
(**repr).alloc / sys::size_of::<T>()
@@ -154,13 +154,6 @@ pure fn len<T>(&&v: [const T]) -> uint unsafe {
154154
(**repr).fill / sys::size_of::<T>()
155155
}
156156

157-
#[doc = "Returns the number of bytes allocated for this vector"]
158-
#[inline(always)]
159-
pure fn alloc_len<T>(&&v: [const T]) -> uint unsafe {
160-
let repr: **unsafe::vec_repr = ::unsafe::reinterpret_cast(addr_of(v));
161-
(**repr).alloc
162-
}
163-
164157
#[doc = "
165158
Creates and initializes an immutable vector.
166159

src/libstd/arena.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl arena for arena {
2525
fn alloc_grow(n_bytes: uint, align: uint) -> *() {
2626
// Allocate a new chunk.
2727
let mut head = list::head(self.chunks);
28-
let chunk_size = vec::alloc_len(head.data);
28+
let chunk_size = vec::capacity(head.data);
2929
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
3030
head = chunk(uint::next_power_of_two(new_min_chunk_size + 1u));
3131
self.chunks = list::cons(head, @self.chunks);
@@ -41,7 +41,7 @@ impl arena for arena {
4141
let mut start = head.fill;
4242
start = (start + alignm1) & !alignm1;
4343
let end = start + n_bytes;
44-
if end > vec::alloc_len(head.data) {
44+
if end > vec::capacity(head.data) {
4545
ret self.alloc_grow(n_bytes, align);
4646
}
4747

0 commit comments

Comments
 (0)