Memoize try_new

This commit is contained in:
mkorje 2025-06-10 20:49:02 +10:00
parent 69392173eb
commit 4ad6b4fc64
No known key found for this signature in database

View File

@ -266,12 +266,13 @@ impl GlyphFragment {
/// Try to create a new glyph out of the given string. Will return None if /// Try to create a new glyph out of the given string. Will return None if
/// the result from shaping the string is not a single glyph or is a tofu. /// the result from shaping the string is not a single glyph or is a tofu.
#[comemo::memoize]
pub fn try_new( pub fn try_new(
font: &Font, font: &Font,
styles: StyleChain, styles: StyleChain,
str: &str, str: &str,
span: Span, span: Span,
) -> Option<Self> { ) -> Option<GlyphFragment> {
let mut buffer = UnicodeBuffer::new(); let mut buffer = UnicodeBuffer::new();
buffer.push_str(str); buffer.push_str(str);
buffer.set_language(language(styles)); buffer.set_language(language(styles));