Auto merge of #18460 - julian-seward1:master, r=emilio

Bug 1398593 - stylo: mitigate performance impact of fallible allocati…

…on on stylist rebuilds.  r=emilio.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18460)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-09-12 15:25:52 -05:00 committed by GitHub
commit 66778851a8
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)?;