Move regexp compilation out of render function so it isn't run once for every single cell

This commit is contained in:
David Dworken 2023-09-24 17:19:51 -07:00
parent 3feb267038
commit e04583f62f
No known key found for this signature in database

View File

@ -584,8 +584,8 @@ func makeTable(ctx context.Context, rows []table.Row) (table.Model, error) {
Background(lipgloss.Color("57")).
Bold(false)
if config.BetaMode {
MATCH_NOTHING_REGEXP := regexp.MustCompile("a^")
s.RenderCell = func(model table.Model, value string, position table.CellPosition) string {
MATCH_NOTHING_REGEXP := regexp.MustCompile("a^")
var re *regexp.Regexp
CURRENT_QUERY_FOR_HIGHLIGHTING = strings.TrimSpace(CURRENT_QUERY_FOR_HIGHLIGHTING)
if CURRENT_QUERY_FOR_HIGHLIGHTING == "" {