x/text/unicode/bidi: consider reusing internal slices #67098
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Go version
go version 1.22
Output of
go env
in your module/workspace:What did you do?
In go-text/typesetting, we use
bidi
to segment the input text. We store and reuse onebidi.Paragraph
object, calling itsSetString
method for each new input.What did you see happen?
The
bidi.Paragraph.prepareInput
method has high memory allocation.What did you expect to see?
Only few allocations. If possible, the slices
pairTypes
,pairValues
,types
should reuse their capacity (instead of being freed and immediately re-allocated).On the same topic,
paragraph.determineLevelRuns
allocates a newrun []int
slice, but it is perhaps harder to get rid of this allocation.The text was updated successfully, but these errors were encountered: