Use Vec instead of SmallVec for glyphs field of ShapedRun (#30664)

This glyphs field is usually larger than 8 elements, and SmallVec is not
efficient when it cannot store the value inline.

This change also adds precise glyphs run preallocation in some places
`ShapedRun` is constructed.

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-05-14 09:02:38 +02:00 committed by GitHub
parent a4766e296f
commit 25cc05b45c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 6 additions and 7 deletions

View file

@ -5,7 +5,6 @@ use anyhow::{Result, anyhow};
use collections::HashMap;
use itertools::Itertools;
use parking_lot::{RwLock, RwLockUpgradableReadGuard};
use smallvec::SmallVec;
use windows::{
Win32::{
Foundation::*,
@ -1089,7 +1088,7 @@ impl IDWriteTextRenderer_Impl for TextRenderer_Impl {
} else {
context.text_system.select_font(&font_struct)
};
let mut glyphs = SmallVec::new();
let mut glyphs = Vec::with_capacity(glyph_count);
for index in 0..glyph_count {
let id = GlyphId(*glyphrun.glyphIndices.add(index) as u32);
context