diff options
| author | P1start <rewi-github@whanau.org> | 2014-08-04 22:48:39 +1200 |
|---|---|---|
| committer | P1start <rewi-github@whanau.org> | 2014-08-19 17:22:18 +1200 |
| commit | f2aa88ca0676249d9c44bb6a2e59cd2b1cdd9c9a (patch) | |
| tree | 50acf564d76caea6531e76609eb44df7671eed70 /src/libarena/lib.rs | |
| parent | eaf810a219b136fff67e75840ad3c5efde9ae1e5 (diff) | |
| download | rust-f2aa88ca0676249d9c44bb6a2e59cd2b1cdd9c9a.tar.gz rust-f2aa88ca0676249d9c44bb6a2e59cd2b1cdd9c9a.zip | |
A few minor documentation fixes
Diffstat (limited to 'src/libarena/lib.rs')
| -rw-r--r-- | src/libarena/lib.rs | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 5d316cdb51e..c2f4ef3ac30 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -7,7 +7,7 @@ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. -// + //! The arena, a fast but limited type of allocator. //! //! Arenas are a type of allocator that destroy the objects within, all at @@ -15,9 +15,9 @@ //! of individual objects while the arena itself is still alive. The benefit //! of an arena is very fast allocation; just a pointer bump. //! -//! This crate has two arenas implemented: TypedArena, which is a simpler -//! arena but can only hold objects of a single type, and Arena, which is a -//! more complex, slower Arena which can hold objects of any type. +//! This crate has two arenas implemented: `TypedArena`, which is a simpler +//! arena but can only hold objects of a single type, and `Arena`, which is a +//! more complex, slower arena which can hold objects of any type. #![crate_name = "arena"] #![experimental] @@ -62,24 +62,24 @@ impl Chunk { /// A slower reflection-based arena that can allocate objects of any type. /// -/// This arena uses Vec<u8> as a backing store to allocate objects from. For +/// This arena uses `Vec<u8>` as a backing store to allocate objects from. For /// each allocated object, the arena stores a pointer to the type descriptor -/// followed by the object. (Potentially with alignment padding after each -/// element.) When the arena is destroyed, it iterates through all of its +/// followed by the object (potentially with alignment padding after each +/// element). When the arena is destroyed, it iterates through all of its /// chunks, and uses the tydesc information to trace through the objects, -/// calling the destructors on them. One subtle point that needs to be +/// calling the destructors on them. One subtle point that needs to be /// addressed is how to handle failures while running the user provided /// initializer function. It is important to not run the destructor on /// uninitialized objects, but how to detect them is somewhat subtle. Since -/// alloc() can be invoked recursively, it is not sufficient to simply exclude +/// `alloc()` can be invoked recursively, it is not sufficient to simply exclude /// the most recent object. To solve this without requiring extra space, we /// use the low order bit of the tydesc pointer to encode whether the object /// it describes has been fully initialized. /// -/// As an optimization, objects with destructors are stored in -/// different chunks than objects without destructors. This reduces -/// overhead when initializing plain-old-data and means we don't need -/// to waste time running the destructors of POD. +/// As an optimization, objects with destructors are stored in different chunks +/// than objects without destructors. This reduces overhead when initializing +/// plain-old-data (`Copy` types) and means we don't need to waste time running +/// their destructors. pub struct Arena { // The head is separated out from the list as a unbenchmarked // microoptimization, to avoid needing to case on the list to access the @@ -90,12 +90,12 @@ pub struct Arena { } impl Arena { - /// Allocate a new Arena with 32 bytes preallocated. + /// Allocates a new Arena with 32 bytes preallocated. pub fn new() -> Arena { Arena::new_with_size(32u) } - /// Allocate a new Arena with `initial_size` bytes preallocated. + /// Allocates a new Arena with `initial_size` bytes preallocated. pub fn new_with_size(initial_size: uint) -> Arena { Arena { head: RefCell::new(chunk(initial_size, false)), @@ -282,8 +282,8 @@ impl Arena { } } - /// Allocate a new item in the arena, using `op` to initialize the value - /// and returning a reference to it. + /// Allocates a new item in the arena, using `op` to initialize the value, + /// and returns a reference to it. #[inline] pub fn alloc<T>(&self, op: || -> T) -> &T { unsafe { @@ -438,13 +438,13 @@ impl<T> TypedArenaChunk<T> { } impl<T> TypedArena<T> { - /// Creates a new TypedArena with preallocated space for 8 objects. + /// Creates a new `TypedArena` with preallocated space for eight objects. #[inline] pub fn new() -> TypedArena<T> { TypedArena::with_capacity(8) } - /// Creates a new TypedArena with preallocated space for the given number of + /// Creates a new `TypedArena` with preallocated space for the given number of /// objects. #[inline] pub fn with_capacity(capacity: uint) -> TypedArena<T> { @@ -456,7 +456,7 @@ impl<T> TypedArena<T> { } } - /// Allocates an object in the TypedArena, returning a reference to it. + /// Allocates an object in the `TypedArena`, returning a reference to it. #[inline] pub fn alloc(&self, object: T) -> &T { if self.ptr == self.end { |
