Skip to content

Commit 5f5c1fa

Browse files
committed
---
yaml --- r: 27946 b: refs/heads/try c: 73a0382 h: refs/heads/master v: v3
1 parent c5f8fe2 commit 5f5c1fa

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
@@ -2,7 +2,7 @@
22
refs/heads/master: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5-
refs/heads/try: f24e0e7b13be0bbead7d7f27b0af5943235c04da
5+
refs/heads/try: 73a03824e8001bb6b050f32870bcaa32866d365c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df

branches/try/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)