Only use relevant info from Attrs as a key in font_matches_cache
`Attrs` contains info like color and metadata which are not relevant to font matching. So, add a new struct `FontMatchAttrs` which only contains the relevant info, and use it as a key in `FontSystem`'s `font_matches_cache`. Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
This commit is contained in:
parent
235ec02a20
commit
e0ae465f91
2 changed files with 23 additions and 3 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{Attrs, AttrsOwned, Font, HashMap, ShapePlanCache};
|
||||
use crate::{Attrs, Font, FontMatchAttrs, HashMap, ShapePlanCache};
|
||||
use alloc::string::String;
|
||||
use alloc::sync::Arc;
|
||||
use alloc::vec::Vec;
|
||||
|
|
@ -27,7 +27,7 @@ pub struct FontSystem {
|
|||
font_cache: HashMap<fontdb::ID, Option<Arc<Font>>>,
|
||||
|
||||
/// Cache for font matches.
|
||||
font_matches_cache: HashMap<AttrsOwned, Arc<Vec<FontMatchKey>>>,
|
||||
font_matches_cache: HashMap<FontMatchAttrs, Arc<Vec<FontMatchKey>>>,
|
||||
|
||||
/// Cache for rustybuzz shape plans.
|
||||
shape_plan_cache: ShapePlanCache,
|
||||
|
|
@ -141,7 +141,7 @@ impl FontSystem {
|
|||
|
||||
self.font_matches_cache
|
||||
//TODO: do not create AttrsOwned unless entry does not already exist
|
||||
.entry(AttrsOwned::new(attrs))
|
||||
.entry(attrs.into())
|
||||
.or_insert_with(|| {
|
||||
#[cfg(all(feature = "std", not(target_arch = "wasm32")))]
|
||||
let now = std::time::Instant::now();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue