diff options
author | 2024-09-15 01:42:04 -0700 | |
---|---|---|
committer | 2024-09-15 10:42:04 +0200 | |
commit | f3311d6273fc60a7bbcfba577c418a236b545b73 (patch) | |
tree | 693b73a20413d3f53cf7c90a2b9b412ec1faddb2 /internal | |
parent | [chore] Update go-sqlite3 to 0.18.3 (#3295) (diff) | |
download | gotosocial-f3311d6273fc60a7bbcfba577c418a236b545b73.tar.xz |
[bugfix] Hoist filterable text field extraction out of loop (#3297)
This doesn't change within the loop, so there's no point in repeating it.
Diffstat (limited to 'internal')
-rw-r--r-- | internal/typeutils/internaltofrontend.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 395603949..55af2c1f1 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -934,6 +934,14 @@ func (c *Converter) statusToAPIFilterResults( } // At this point, the status isn't muted, but might still be filtered. + if len(filters) == 0 { + // If it can't be filtered because there are no filters, we're done. + return nil, nil + } + + // Extract text fields from the status that we will match filters against. + fields := filterableTextFields(s) + // Record all matching warn filters and the reasons they matched. filterResults := make([]apimodel.FilterResult, 0, len(filters)) for _, filter := range filters { @@ -947,7 +955,6 @@ func (c *Converter) statusToAPIFilterResults( // List all matching keywords. keywordMatches := make([]string, 0, len(filter.Keywords)) - fields := filterableTextFields(s) for _, filterKeyword := range filter.Keywords { var isMatch bool for _, field := range fields { |