Skip to content

Commit dd550b5

Browse files
committed
---
yaml --- r: 29968 b: refs/heads/incoming c: 73a0382 h: refs/heads/master v: v3
1 parent e0bd85d commit dd550b5

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: f24e0e7b13be0bbead7d7f27b0af5943235c04da
9+
refs/heads/incoming: 73a03824e8001bb6b050f32870bcaa32866d365c
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libstd/arena.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ const tydesc_drop_glue_index: size_t = 3 as size_t;
4646
// The way arena uses arrays is really deeply awful. The arrays are
4747
// allocated, and have capacities reserved, but the fill for the array
4848
// will always stay at 0.
49-
type chunk = {data: ~[u8], mut fill: uint, is_pod: bool};
49+
type chunk = {data: @[u8], mut fill: uint, is_pod: bool};
5050

5151
struct arena {
5252
// The head is seperated out from the list as a unbenchmarked
5353
// microoptimization, to avoid needing to case on the list to
5454
// access the head.
55-
priv mut head: @chunk;
56-
priv mut pod_head: @chunk;
57-
priv mut chunks: @list<@chunk>;
55+
priv mut head: chunk;
56+
priv mut pod_head: chunk;
57+
priv mut chunks: @list<chunk>;
5858
drop {
5959
unsafe {
6060
destroy_chunk(self.head);
@@ -65,10 +65,10 @@ struct arena {
6565
}
6666
}
6767

68-
fn chunk(size: uint, is_pod: bool) -> @chunk {
69-
let mut v = ~[];
70-
vec::reserve(v, size);
71-
@{ data: v, mut fill: 0u, is_pod: is_pod }
68+
fn chunk(size: uint, is_pod: bool) -> chunk {
69+
let mut v = @[];
70+
unsafe { at_vec::unsafe::reserve(v, size); }
71+
{ data: v, mut fill: 0u, is_pod: is_pod }
7272
}
7373

7474
fn arena_with_size(initial_size: uint) -> arena {
@@ -88,9 +88,9 @@ fn round_up_to(base: uint, align: uint) -> uint {
8888

8989
// Walk down a chunk, running the destructors for any objects stored
9090
// in it.
91-
unsafe fn destroy_chunk(chunk: @chunk) {
91+
unsafe fn destroy_chunk(chunk: chunk) {
9292
let mut idx = 0;
93-
let buf = vec::unsafe::to_ptr(chunk.data);
93+
let buf = vec::unsafe::to_ptr_slice(chunk.data);
9494
let fill = chunk.fill;
9595

9696
while idx < fill {
@@ -133,9 +133,9 @@ impl &arena {
133133
// Functions for the POD part of the arena
134134
fn alloc_pod_grow(n_bytes: uint, align: uint) -> *u8 {
135135
// Allocate a new chunk.
136-
let chunk_size = vec::capacity(self.pod_head.data);
136+
let chunk_size = at_vec::capacity(self.pod_head.data);
137137
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
138-
self.chunks = @cons(self.pod_head, self.chunks);
138+
self.chunks = @cons(copy self.pod_head, self.chunks);
139139
self.pod_head =
140140
chunk(uint::next_power_of_two(new_min_chunk_size + 1u), true);
141141

@@ -144,11 +144,11 @@ impl &arena {
144144

145145
#[inline(always)]
146146
fn alloc_pod_inner(n_bytes: uint, align: uint) -> *u8 {
147-
let head = self.pod_head;
147+
let head = &mut self.pod_head;
148148

149149
let start = round_up_to(head.fill, align);
150150
let end = start + n_bytes;
151-
if end > vec::capacity(head.data) {
151+
if end > at_vec::capacity(head.data) {
152152
return self.alloc_pod_grow(n_bytes, align);
153153
}
154154
head.fill = end;
@@ -157,7 +157,7 @@ impl &arena {
157157
// start, n_bytes, align, head.fill);
158158

159159
unsafe {
160-
ptr::offset(vec::unsafe::to_ptr(head.data), start)
160+
ptr::offset(vec::unsafe::to_ptr_slice(head.data), start)
161161
}
162162
}
163163

@@ -175,9 +175,9 @@ impl &arena {
175175
// Functions for the non-POD part of the arena
176176
fn alloc_nonpod_grow(n_bytes: uint, align: uint) -> (*u8, *u8) {
177177
// Allocate a new chunk.
178-
let chunk_size = vec::capacity(self.head.data);
178+
let chunk_size = at_vec::capacity(self.head.data);
179179
let new_min_chunk_size = uint::max(n_bytes, chunk_size);
180-
self.chunks = @cons(self.head, self.chunks);
180+
self.chunks = @cons(copy self.head, self.chunks);
181181
self.head =
182182
chunk(uint::next_power_of_two(new_min_chunk_size + 1u), false);
183183

@@ -186,13 +186,13 @@ impl &arena {
186186

187187
#[inline(always)]
188188
fn alloc_nonpod_inner(n_bytes: uint, align: uint) -> (*u8, *u8) {
189-
let head = self.head;
189+
let head = &mut self.head;
190190

191191
let tydesc_start = head.fill;
192192
let after_tydesc = head.fill + sys::size_of::<*TypeDesc>();
193193
let start = round_up_to(after_tydesc, align);
194194
let end = start + n_bytes;
195-
if end > vec::capacity(head.data) {
195+
if end > at_vec::capacity(head.data) {
196196
return self.alloc_nonpod_grow(n_bytes, align);
197197
}
198198
head.fill = round_up_to(end, sys::pref_align_of::<*TypeDesc>());
@@ -201,7 +201,7 @@ impl &arena {
201201
// start, n_bytes, align, head.fill);
202202

203203
unsafe {
204-
let buf = vec::unsafe::to_ptr(head.data);
204+
let buf = vec::unsafe::to_ptr_slice(head.data);
205205
return (ptr::offset(buf, tydesc_start), ptr::offset(buf, start));
206206
}
207207
}

0 commit comments

Comments
 (0)