From a83d2afbba772f474872aacc6c21f2b5270fc517 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Aug 2017 15:58:26 -0700 Subject: [PATCH] std: Tag `AllocErr` functions as `#[inline]` None of these require a significant amount of code and using `#[inline]` will allow constructors to get inlined, improving codegen at allocation callsites. --- src/liballoc/allocator.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/liballoc/allocator.rs b/src/liballoc/allocator.rs index 42111301a9f..181eb7466d7 100644 --- a/src/liballoc/allocator.rs +++ b/src/liballoc/allocator.rs @@ -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",