diff options
| author | bors <bors@rust-lang.org> | 2017-08-13 19:28:57 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-08-13 19:28:57 +0000 |
| commit | ab40a7cb0e01159a04d4cfffc432c6d77f1f23c8 (patch) | |
| tree | 23a6ba2f2c3b1b022fed48b52839c713428d6140 /src/liballoc/allocator.rs | |
| parent | a80a873209a79499290201f8657618703a51b73e (diff) | |
| parent | 3a831653d06ceef975b80ef4e41ee0679b44c364 (diff) | |
| download | rust-ab40a7cb0e01159a04d4cfffc432c6d77f1f23c8.tar.gz rust-ab40a7cb0e01159a04d4cfffc432c6d77f1f23c8.zip | |
Auto merge of #43815 - alexcrichton:optimize-alloc, r=sfackler
Optimize allocation paths in RawVec Since the `Alloc` trait was introduced (https://github.com/rust-lang/rust/pull/42313) and it was integrated everywhere (https://github.com/rust-lang/rust/pull/42727) there's been some slowdowns and regressions that have slipped through. The intention of this PR is to try to tackle at least some of them, but they've been very difficult to quantify up to this point so it probably doesn't solve everything. This PR primarily targets the `RawVec` type, specifically the `double` function. The codegen for this function is now much closer to what it was before #42313 landed as many runtime checks have been elided.
Diffstat (limited to 'src/liballoc/allocator.rs')
| -rw-r--r-- | src/liballoc/allocator.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/liballoc/allocator.rs b/src/liballoc/allocator.rs index 7b6700bfd49..2b3df15f716 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", |
