Use a scratch buffer to reduce allocations

This commit adds a new ShapeBuffer type, which contains some buffers tha
are commonly re-created during the shaping process. New APIs are added
that take this structure, and old APIs are turned into wrappers around
the new API.

The goal is to reduce the number of per-layout allocations that happen
in a typical layout call.
This commit is contained in:
John Nunley 2023-07-18 19:18:56 -07:00 committed by John Nunley
parent d7214b5417
commit 64e469718b
4 changed files with 265 additions and 66 deletions

View file

@ -36,7 +36,7 @@ pub struct FontFallbackIter<'a> {
font_ids: &'a [fontdb::ID],
default_families: &'a [&'a Family<'a>],
default_i: usize,
scripts: Vec<Script>,
scripts: &'a [Script],
script_i: (usize, usize),
common_i: usize,
other_i: usize,
@ -48,7 +48,7 @@ impl<'a> FontFallbackIter<'a> {
font_system: &'a mut FontSystem,
font_ids: &'a [fontdb::ID],
default_families: &'a [&'a Family<'a>],
scripts: Vec<Script>,
scripts: &'a [Script],
) -> Self {
Self {
font_system,