Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor libcollections::List, add documentation #13011

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

extern crate collections;

use collections::list::{List, Cons, Nil};
use collections::list::List;

use std::cast::{transmute, transmute_mut, transmute_mut_region};
use std::cast;
Expand Down Expand Up @@ -90,7 +90,7 @@ pub struct Arena {
// access the head.
priv head: Chunk,
priv pod_head: Chunk,
priv chunks: RefCell<@List<Chunk>>,
priv chunks: List<Chunk>,
priv no_freeze: marker::NoFreeze,
}

Expand All @@ -103,7 +103,7 @@ impl Arena {
Arena {
head: chunk(initial_size, false),
pod_head: chunk(initial_size, true),
chunks: RefCell::new(@Nil),
chunks: List::new(),
no_freeze: marker::NoFreeze,
}
}
Expand All @@ -122,7 +122,7 @@ impl Drop for Arena {
fn drop(&mut self) {
unsafe {
destroy_chunk(&self.head);
for chunk in self.chunks.get().iter() {
for chunk in self.chunks.iter() {
if !chunk.is_pod.get() {
destroy_chunk(chunk);
}
Expand Down Expand Up @@ -184,7 +184,7 @@ impl Arena {
fn alloc_pod_grow(&mut self, n_bytes: uint, align: uint) -> *u8 {
// Allocate a new chunk.
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
self.chunks.set(@Cons(self.pod_head.clone(), self.chunks.get()));
self.chunks.push(self.pod_head.clone());
self.pod_head =
chunk(num::next_power_of_two(new_min_chunk_size + 1u), true);

Expand Down Expand Up @@ -224,7 +224,7 @@ impl Arena {
-> (*u8, *u8) {
// Allocate a new chunk.
let new_min_chunk_size = cmp::max(n_bytes, self.chunk_size());
self.chunks.set(@Cons(self.head.clone(), self.chunks.get()));
self.chunks.push(self.head.clone());
self.head =
chunk(num::next_power_of_two(new_min_chunk_size + 1u), false);

Expand Down
Loading