Skip to content

Commit

Permalink
std: Tag AllocErr functions as #[inline]
Browse files Browse the repository at this point in the history
None of these require a significant amount of code and using `#[inline]` will
allow constructors to get inlined, improving codegen at allocation callsites.
  • Loading branch information
alexcrichton committed Aug 11, 2017
1 parent edd82ee commit a83d2af
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/liballoc/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,19 @@ pub enum AllocErr {
}

impl AllocErr {
#[inline]
pub fn invalid_input(details: &'static str) -> Self {
AllocErr::Unsupported { details: details }
}
#[inline]
pub fn is_memory_exhausted(&self) -> bool {
if let AllocErr::Exhausted { .. } = *self { true } else { false }
}
#[inline]
pub fn is_request_unsupported(&self) -> bool {
if let AllocErr::Unsupported { .. } = *self { true } else { false }
}
#[inline]
pub fn description(&self) -> &str {
match *self {
AllocErr::Exhausted { .. } => "allocator memory exhausted",
Expand Down

0 comments on commit a83d2af

Please sign in to comment.