@@ -48,7 +48,7 @@ use std::intrinsics;
4848struct Chunk {
4949 data : Rc < RefCell < Vec < u8 > > > ,
5050 fill : Cell < uint > ,
51- is_pod : Cell < bool > ,
51+ is_copy : Cell < bool > ,
5252}
5353impl Chunk {
5454 fn capacity ( & self ) -> uint {
@@ -86,7 +86,7 @@ pub struct Arena {
8686 // microoptimization, to avoid needing to case on the list to
8787 // access the head.
8888 priv head : Chunk ,
89- priv pod_head : Chunk ,
89+ priv copy_head : Chunk ,
9090 priv chunks : RefCell < @List < Chunk > > ,
9191}
9292
@@ -98,17 +98,17 @@ impl Arena {
9898 pub fn new_with_size ( initial_size : uint ) -> Arena {
9999 Arena {
100100 head : chunk ( initial_size, false ) ,
101- pod_head : chunk ( initial_size, true ) ,
101+ copy_head : chunk ( initial_size, true ) ,
102102 chunks : RefCell :: new ( @Nil ) ,
103103 }
104104 }
105105}
106106
107- fn chunk ( size : uint , is_pod : bool ) -> Chunk {
107+ fn chunk ( size : uint , is_copy : bool ) -> Chunk {
108108 Chunk {
109109 data : Rc :: new ( RefCell :: new ( Vec :: with_capacity ( size) ) ) ,
110110 fill : Cell :: new ( 0 u) ,
111- is_pod : Cell :: new ( is_pod ) ,
111+ is_copy : Cell :: new ( is_copy ) ,
112112 }
113113}
114114
@@ -118,7 +118,7 @@ impl Drop for Arena {
118118 unsafe {
119119 destroy_chunk ( & self . head ) ;
120120 for chunk in self . chunks . get ( ) . iter ( ) {
121- if !chunk. is_pod . get ( ) {
121+ if !chunk. is_copy . get ( ) {
122122 destroy_chunk ( chunk) ;
123123 }
124124 }
@@ -173,61 +173,61 @@ fn un_bitpack_tydesc_ptr(p: uint) -> (*TyDesc, bool) {
173173
174174impl Arena {
175175 fn chunk_size ( & self ) -> uint {
176- self . pod_head . capacity ( )
176+ self . copy_head . capacity ( )
177177 }
178178 // Functions for the POD part of the arena
179- fn alloc_pod_grow ( & mut self , n_bytes : uint , align : uint ) -> * u8 {
179+ fn alloc_copy_grow ( & mut self , n_bytes : uint , align : uint ) -> * u8 {
180180 // Allocate a new chunk.
181181 let new_min_chunk_size = cmp:: max ( n_bytes, self . chunk_size ( ) ) ;
182- self . chunks . set ( @Cons ( self . pod_head . clone ( ) , self . chunks . get ( ) ) ) ;
183- self . pod_head =
182+ self . chunks . set ( @Cons ( self . copy_head . clone ( ) , self . chunks . get ( ) ) ) ;
183+ self . copy_head =
184184 chunk ( num:: next_power_of_two ( new_min_chunk_size + 1 u) , true ) ;
185185
186- return self . alloc_pod_inner ( n_bytes, align) ;
186+ return self . alloc_copy_inner ( n_bytes, align) ;
187187 }
188188
189189 #[ inline]
190- fn alloc_pod_inner ( & mut self , n_bytes : uint , align : uint ) -> * u8 {
190+ fn alloc_copy_inner ( & mut self , n_bytes : uint , align : uint ) -> * u8 {
191191 unsafe {
192192 let this = transmute_mut_region ( self ) ;
193- let start = round_up ( this. pod_head . fill . get ( ) , align) ;
193+ let start = round_up ( this. copy_head . fill . get ( ) , align) ;
194194 let end = start + n_bytes;
195195 if end > self . chunk_size ( ) {
196- return this. alloc_pod_grow ( n_bytes, align) ;
196+ return this. alloc_copy_grow ( n_bytes, align) ;
197197 }
198- this. pod_head . fill . set ( end) ;
198+ this. copy_head . fill . set ( end) ;
199199
200200 //debug!("idx = {}, size = {}, align = {}, fill = {}",
201201 // start, n_bytes, align, head.fill.get());
202202
203- this. pod_head . as_ptr ( ) . offset ( start as int )
203+ this. copy_head . as_ptr ( ) . offset ( start as int )
204204 }
205205 }
206206
207207 #[ inline]
208- fn alloc_pod < ' a , T > ( & ' a mut self , op: || -> T ) -> & ' a T {
208+ fn alloc_copy < ' a , T > ( & ' a mut self , op: || -> T ) -> & ' a T {
209209 unsafe {
210- let ptr = self . alloc_pod_inner ( mem:: size_of :: < T > ( ) , mem:: min_align_of :: < T > ( ) ) ;
210+ let ptr = self . alloc_copy_inner ( mem:: size_of :: < T > ( ) , mem:: min_align_of :: < T > ( ) ) ;
211211 let ptr: * mut T = transmute ( ptr) ;
212212 mem:: move_val_init ( & mut ( * ptr) , op ( ) ) ;
213213 return transmute ( ptr) ;
214214 }
215215 }
216216
217217 // Functions for the non-POD part of the arena
218- fn alloc_nonpod_grow ( & mut self , n_bytes : uint , align : uint )
218+ fn alloc_noncopy_grow ( & mut self , n_bytes : uint , align : uint )
219219 -> ( * u8 , * u8 ) {
220220 // Allocate a new chunk.
221221 let new_min_chunk_size = cmp:: max ( n_bytes, self . chunk_size ( ) ) ;
222222 self . chunks . set ( @Cons ( self . head . clone ( ) , self . chunks . get ( ) ) ) ;
223223 self . head =
224224 chunk ( num:: next_power_of_two ( new_min_chunk_size + 1 u) , false ) ;
225225
226- return self . alloc_nonpod_inner ( n_bytes, align) ;
226+ return self . alloc_noncopy_inner ( n_bytes, align) ;
227227 }
228228
229229 #[ inline]
230- fn alloc_nonpod_inner ( & mut self , n_bytes : uint , align : uint )
230+ fn alloc_noncopy_inner ( & mut self , n_bytes : uint , align : uint )
231231 -> ( * u8 , * u8 ) {
232232 unsafe {
233233 let start;
@@ -245,7 +245,7 @@ impl Arena {
245245 }
246246
247247 if end > self . head . capacity ( ) {
248- return self . alloc_nonpod_grow ( n_bytes, align) ;
248+ return self . alloc_noncopy_grow ( n_bytes, align) ;
249249 }
250250
251251 let head = transmute_mut_region ( & mut self . head ) ;
@@ -260,11 +260,11 @@ impl Arena {
260260 }
261261
262262 #[ inline]
263- fn alloc_nonpod < ' a , T > ( & ' a mut self , op: || -> T ) -> & ' a T {
263+ fn alloc_noncopy < ' a , T > ( & ' a mut self , op: || -> T ) -> & ' a T {
264264 unsafe {
265265 let tydesc = get_tydesc :: < T > ( ) ;
266266 let ( ty_ptr, ptr) =
267- self . alloc_nonpod_inner ( mem:: size_of :: < T > ( ) , mem:: min_align_of :: < T > ( ) ) ;
267+ self . alloc_noncopy_inner ( mem:: size_of :: < T > ( ) , mem:: min_align_of :: < T > ( ) ) ;
268268 let ty_ptr: * mut uint = transmute ( ty_ptr) ;
269269 let ptr: * mut T = transmute ( ptr) ;
270270 // Write in our tydesc along with a bit indicating that it
@@ -287,9 +287,9 @@ impl Arena {
287287 // FIXME: Borrow check
288288 let this = transmute_mut ( self ) ;
289289 if intrinsics:: needs_drop :: < T > ( ) {
290- this. alloc_nonpod ( op)
290+ this. alloc_noncopy ( op)
291291 } else {
292- this. alloc_pod ( op)
292+ this. alloc_copy ( op)
293293 }
294294 }
295295 }
@@ -496,7 +496,7 @@ mod tests {
496496 }
497497
498498 #[ test]
499- pub fn test_pod ( ) {
499+ pub fn test_copy ( ) {
500500 let arena = TypedArena :: new ( ) ;
501501 for _ in range ( 0 , 100000 ) {
502502 arena. alloc ( Point {
@@ -508,7 +508,7 @@ mod tests {
508508 }
509509
510510 #[ bench]
511- pub fn bench_pod ( bh : & mut BenchHarness ) {
511+ pub fn bench_copy ( bh : & mut BenchHarness ) {
512512 let arena = TypedArena :: new ( ) ;
513513 bh. iter ( || {
514514 arena. alloc ( Point {
@@ -520,7 +520,7 @@ mod tests {
520520 }
521521
522522 #[ bench]
523- pub fn bench_pod_nonarena ( bh : & mut BenchHarness ) {
523+ pub fn bench_copy_nonarena ( bh : & mut BenchHarness ) {
524524 bh. iter ( || {
525525 ~Point {
526526 x : 1 ,
@@ -531,7 +531,7 @@ mod tests {
531531 }
532532
533533 #[ bench]
534- pub fn bench_pod_old_arena ( bh : & mut BenchHarness ) {
534+ pub fn bench_copy_old_arena ( bh : & mut BenchHarness ) {
535535 let arena = Arena :: new ( ) ;
536536 bh. iter ( || {
537537 arena. alloc ( || {
@@ -544,48 +544,48 @@ mod tests {
544544 } )
545545 }
546546
547- struct Nonpod {
547+ struct Noncopy {
548548 string : ~str ,
549549 array : Vec < int > ,
550550 }
551551
552552 #[ test]
553- pub fn test_nonpod ( ) {
553+ pub fn test_noncopy ( ) {
554554 let arena = TypedArena :: new ( ) ;
555555 for _ in range ( 0 , 100000 ) {
556- arena. alloc ( Nonpod {
556+ arena. alloc ( Noncopy {
557557 string : ~"hello world",
558558 array : vec ! ( 1 , 2 , 3 , 4 , 5 ) ,
559559 } ) ;
560560 }
561561 }
562562
563563 #[ bench]
564- pub fn bench_nonpod ( bh : & mut BenchHarness ) {
564+ pub fn bench_noncopy ( bh : & mut BenchHarness ) {
565565 let arena = TypedArena :: new ( ) ;
566566 bh. iter ( || {
567- arena. alloc ( Nonpod {
567+ arena. alloc ( Noncopy {
568568 string : ~"hello world",
569569 array : vec ! ( 1 , 2 , 3 , 4 , 5 ) ,
570570 } )
571571 } )
572572 }
573573
574574 #[ bench]
575- pub fn bench_nonpod_nonarena ( bh : & mut BenchHarness ) {
575+ pub fn bench_noncopy_nonarena ( bh : & mut BenchHarness ) {
576576 bh. iter ( || {
577- ~Nonpod {
577+ ~Noncopy {
578578 string : ~"hello world",
579579 array : vec ! ( 1 , 2 , 3 , 4 , 5 ) ,
580580 }
581581 } )
582582 }
583583
584584 #[ bench]
585- pub fn bench_nonpod_old_arena ( bh : & mut BenchHarness ) {
585+ pub fn bench_noncopy_old_arena ( bh : & mut BenchHarness ) {
586586 let arena = Arena :: new ( ) ;
587587 bh. iter ( || {
588- arena. alloc ( || Nonpod {
588+ arena. alloc ( || Noncopy {
589589 string : ~"hello world",
590590 array : vec ! ( 1 , 2 , 3 , 4 , 5 ) ,
591591 } )
0 commit comments