Skip to content

Commit

Permalink
[harfbuzz] reduce memory allocation (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitkugler authored May 2, 2024
1 parent d9a73b1 commit 94e638b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions harfbuzz/ot_shaper.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,14 +763,13 @@ type shaperOpentype struct {

type otShapePlanKey = [2]int // -1 for not found

func newShaperOpentype(tables *font.Font, coords []tables.Coord) *shaperOpentype {
var out shaperOpentype
out.key = otShapePlanKey{
func (sp *shaperOpentype) init(tables *font.Font, coords []tables.Coord) {
sp.plan = otShapePlan{}
sp.key = otShapePlanKey{
0: tables.GSUB.FindVariationIndex(coords),
1: tables.GPOS.FindVariationIndex(coords),
}
out.tables = tables
return &out
sp.tables = tables
}

func (sp *shaperOpentype) compile(props SegmentProperties, userFeatures []Feature) {
Expand Down
4 changes: 2 additions & 2 deletions harfbuzz/shape.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (b *Buffer) Shape(font *Font, features []Feature) {
//
// Most client programs will not need to deal with shape plans directly.
type shapePlan struct {
shaper *shaperOpentype
shaper shaperOpentype
props SegmentProperties
userFeatures []Feature
}
Expand All @@ -68,7 +68,7 @@ func (plan *shapePlan) init(copy bool, font *Font, props SegmentProperties,
}

// init shaper
plan.shaper = newShaperOpentype(font.face.Font, coords)
plan.shaper.init(font.face.Font, coords)
}

func (plan shapePlan) userFeaturesMatch(other shapePlan) bool {
Expand Down

0 comments on commit 94e638b

Please sign in to comment.