mirror of
https://github.com/servo/servo.git
synced 2025-10-08 04:29:24 +01:00
style: Use fallible allocation for stylesheet invalidation.
If the sets get too big we cannot allocate anything else, we'll just empty them and invalidate the whole document. Differential Revision: https://phabricator.services.mozilla.com/D46828
This commit is contained in:
parent
c349dbbaa9
commit
3cb18071a2
2 changed files with 27 additions and 10 deletions
|
@ -17,6 +17,8 @@ use std::ops::{BitAnd, BitOr, BitXor, Sub};
|
|||
use super::hash_map::{self, HashMap, Keys, RandomState};
|
||||
use super::Recover;
|
||||
|
||||
use crate::FailedAllocationError;
|
||||
|
||||
// Future Optimization (FIXME!)
|
||||
// =============================
|
||||
//
|
||||
|
@ -589,6 +591,12 @@ where
|
|||
self.map.insert(value, ()).is_none()
|
||||
}
|
||||
|
||||
/// Fallible version of `insert`.
|
||||
#[inline]
|
||||
pub fn try_insert(&mut self, value: T) -> Result<bool, FailedAllocationError> {
|
||||
Ok(self.map.try_insert(value, ())?.is_none())
|
||||
}
|
||||
|
||||
/// Adds a value to the set, replacing the existing value, if any, that is equal to the given
|
||||
/// one. Returns the replaced value.
|
||||
pub fn replace(&mut self, value: T) -> Option<T> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue