Drop ShapePlanCache
The ShapePlanCache was added to improve performance when shaping the same strings over and over. However, it never had the ability to be trimmed and when it was moved to FontSystem, this created a permanently growing allocation. It is recommended to instead use the shape-run-cache feature which supports trimming if it is desired to have higher performance for repeated shaping, at the cost of manually specifying when to trim.
This commit is contained in:
parent
4fe90bb612
commit
1f4065c1c3
5 changed files with 40 additions and 112 deletions
|
|
@ -5,7 +5,7 @@ use alloc::vec::Vec;
|
|||
use fontdb::Family;
|
||||
use unicode_script::Script;
|
||||
|
||||
use crate::{Font, FontMatchKey, FontSystem, ShapeBuffer, ShapePlanCache};
|
||||
use crate::{Font, FontMatchKey, FontSystem, ShapeBuffer};
|
||||
|
||||
use self::platform::*;
|
||||
|
||||
|
|
@ -117,11 +117,8 @@ impl<'a> FontFallbackIter<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn shape_caches(&mut self) -> (&mut ShapeBuffer, &mut ShapePlanCache) {
|
||||
(
|
||||
&mut self.font_system.shape_buffer,
|
||||
&mut self.font_system.shape_plan_cache,
|
||||
)
|
||||
pub fn shape_caches(&mut self) -> &mut ShapeBuffer {
|
||||
&mut self.font_system.shape_buffer
|
||||
}
|
||||
|
||||
fn face_contains_family(&self, id: fontdb::ID, family_name: &str) -> bool {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{Attrs, Font, FontMatchAttrs, HashMap, ShapeBuffer, ShapePlanCache};
|
||||
use crate::{Attrs, Font, FontMatchAttrs, HashMap, ShapeBuffer};
|
||||
use alloc::collections::BTreeSet;
|
||||
use alloc::string::String;
|
||||
use alloc::sync::Arc;
|
||||
|
|
@ -103,9 +103,6 @@ pub struct FontSystem {
|
|||
/// Cache for font matches.
|
||||
font_matches_cache: HashMap<FontMatchAttrs, Arc<Vec<FontMatchKey>>>,
|
||||
|
||||
/// Cache for rustybuzz shape plans.
|
||||
pub(crate) shape_plan_cache: ShapePlanCache,
|
||||
|
||||
/// Scratch buffer for shaping and laying out.
|
||||
pub(crate) shape_buffer: ShapeBuffer,
|
||||
|
||||
|
|
@ -177,7 +174,6 @@ impl FontSystem {
|
|||
font_cache: Default::default(),
|
||||
font_matches_cache: Default::default(),
|
||||
font_codepoint_support_info_cache: Default::default(),
|
||||
shape_plan_cache: ShapePlanCache::default(),
|
||||
monospace_fallbacks_buffer: BTreeSet::default(),
|
||||
#[cfg(feature = "shape-run-cache")]
|
||||
shape_run_cache: crate::ShapeRunCache::default(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue