From 6bd98ed6d7705a3bdc402a6ef2bae330c98dd5df Mon Sep 17 00:00:00 2001 From: Brandon Fulljames Date: Tue, 28 Mar 2023 23:48:18 +0900 Subject: [PATCH] Don't check filter input value for each row --- table/filter.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/table/filter.go b/table/filter.go index 02f0d6b..0ba233b 100644 --- a/table/filter.go +++ b/table/filter.go @@ -6,14 +6,15 @@ import ( ) func (m Model) getFilteredRows(rows []Row) []Row { - if !m.filtered || m.filterTextInput.Value() == "" { + filterInputValue := m.filterTextInput.Value() + if !m.filtered || filterInputValue == "" { return rows } filteredRows := make([]Row, 0) for _, row := range rows { - if isRowMatched(m.columns, row, m.filterTextInput.Value()) { + if isRowMatched(m.columns, row, filterInputValue) { filteredRows = append(filteredRows, row) } }