style: Refactor the author sheet cache to keep alive the relevant StylesheetContents

This prevents incorrectly reusing cached results when the contents go
away and new contents are allocated with the same address.

Note that these keep alive transitively everything else under them, so
all other medialist keys don't need this.

By making this a proper hashmap it should also improve cache lookup
times if the cache grows too big.

Differential Revision: https://phabricator.services.mozilla.com/D115202
This commit is contained in:
Emilio Cobos Álvarez 2023-05-21 21:32:19 +02:00 committed by Oriol Brufau
parent 9c32836913
commit 1ddd3b09c2
3 changed files with 126 additions and 55 deletions

View file

@ -248,6 +248,14 @@ impl<T> Arc<T> {
}
}
/// Like from_raw, but returns an addrefed arc instead.
#[inline]
pub unsafe fn from_raw_addrefed(ptr: *const T) -> Self {
let arc = Self::from_raw(ptr);
mem::forget(arc.clone());
arc
}
/// Create a new static Arc<T> (one that won't reference count the object)
/// and place it in the allocation provided by the specified `alloc`
/// function.