diff --git a/pkg/hicli/html.go b/pkg/hicli/html.go index 569549c..b6b2b21 100644 --- a/pkg/hicli/html.go +++ b/pkg/hicli/html.go @@ -505,9 +505,12 @@ func getCodeBlockLanguage(token html.Token) string { return "" } +const builderPreallocBuffer = 100 + func sanitizeAndLinkifyHTML(body string) (string, []id.ContentURI, error) { tz := html.NewTokenizer(strings.NewReader(body)) var built strings.Builder + built.Grow(len(body) + builderPreallocBuffer) var codeBlock *strings.Builder var codeBlockLanguage string var inlineImages []id.ContentURI diff --git a/pkg/hicli/sync.go b/pkg/hicli/sync.go index 953fd4c..467d996 100644 --- a/pkg/hicli/sync.go +++ b/pkg/hicli/sync.go @@ -384,6 +384,7 @@ func (h *HiClient) calculateLocalContent(ctx context.Context, dbEvt *database.Ev } } else { var builder strings.Builder + builder.Grow(len(content.Body) + builderPreallocBuffer) linkifyAndWriteBytes(&builder, []byte(content.Body)) sanitizedHTML = builder.String() wasPlaintext = true