Skip to content

Commit 822a235

Browse files
committed
chore: Wrap glyph shape variants with a Box
The GlyphShape enum contains three variants, all of them differ in size. The None variant is used rarely, but the Swf variant isn't. By boxing Swf and Drawing, we can reduce the amount of wasted memory.
1 parent a70299a commit 822a235

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

core/src/font.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl FontFace {
220220
);
221221
Some(Glyph {
222222
shape_handle: Default::default(),
223-
shape: GlyphShape::Drawing(drawing),
223+
shape: GlyphShape::Drawing(Box::new(drawing)),
224224
advance,
225225
character,
226226
})
@@ -446,7 +446,9 @@ impl<'gc> Font<'gc> {
446446
let glyph = Glyph {
447447
shape_handle: None.into(),
448448
advance: Twips::new(swf_glyph.advance.into()),
449-
shape: GlyphShape::Swf(RefCell::new(SwfGlyphOrShape::Glyph(swf_glyph))),
449+
shape: GlyphShape::Swf(RefCell::new(Box::new(SwfGlyphOrShape::Glyph(
450+
swf_glyph,
451+
)))),
450452
character,
451453
};
452454

@@ -817,8 +819,8 @@ impl SwfGlyphOrShape {
817819

818820
#[derive(Debug, Clone)]
819821
enum GlyphShape {
820-
Swf(RefCell<SwfGlyphOrShape>),
821-
Drawing(Drawing),
822+
Swf(RefCell<Box<SwfGlyphOrShape>>),
823+
Drawing(Box<Drawing>),
822824
None,
823825
}
824826

0 commit comments

Comments
 (0)