Bug 1398593 - stylo: mitigate performance impact of fallible allocation on stylist rebuilds. r=emilio.

This commit is contained in:
Julian Seward 2017-09-12 15:18:49 +02:00
parent 61fac2c10d
commit e7e03fac7b
2 changed files with 3 additions and 2 deletions

View file

@ -27,7 +27,7 @@ pub trait FallibleVec<T> {
// Vec
impl<T> FallibleVec<T> for Vec<T> {
#[inline]
#[inline(always)]
fn try_push(&mut self, val: T) -> Result<(), FailedAllocationError> {
#[cfg(feature = "known_system_malloc")]
{
@ -92,7 +92,7 @@ fn try_double_vec<T>(vec: &mut Vec<T>) -> Result<(), FailedAllocationError> {
// SmallVec
impl<T: Array> FallibleVec<T::Item> for SmallVec<T> {
#[inline]
#[inline(always)]
fn try_push(&mut self, val: T::Item) -> Result<(), FailedAllocationError> {
#[cfg(feature = "known_system_malloc")]
{

View file

@ -1002,6 +1002,7 @@ impl<K, V, S> HashMap<K, V, S>
self.try_entry(key).unwrap()
}
#[inline(always)]
pub fn try_entry(&mut self, key: K) -> Result<Entry<K, V>, FailedAllocationError> {
// Gotta resize now.
self.try_reserve(1)?;