filtering: preallocate allow filters slice

This commit is contained in:
tdakkota 2024-11-14 23:31:30 +03:00
parent 1d6d85cff4
commit aeb31f56e1
No known key found for this signature in database
GPG Key ID: 01A06F025C62F7CC
1 changed files with 2 additions and 2 deletions

View File

@ -593,7 +593,7 @@ func (d *DNSFilter) EnableFilters(async bool) {
} }
func (d *DNSFilter) enableFiltersLocked(async bool) { func (d *DNSFilter) enableFiltersLocked(async bool) {
filters := make([]Filter, 1, len(d.conf.Filters)+len(d.conf.WhitelistFilters)+1) filters := make([]Filter, 1, len(d.conf.Filters)+1)
filters[0] = Filter{ filters[0] = Filter{
ID: rulelist.URLFilterIDCustom, ID: rulelist.URLFilterIDCustom,
Data: []byte(strings.Join(d.conf.UserRules, "\n")), Data: []byte(strings.Join(d.conf.UserRules, "\n")),
@ -610,7 +610,7 @@ func (d *DNSFilter) enableFiltersLocked(async bool) {
}) })
} }
var allowFilters []Filter allowFilters := make([]Filter, 0, len(d.conf.WhitelistFilters))
for _, filter := range d.conf.WhitelistFilters { for _, filter := range d.conf.WhitelistFilters {
if !filter.Enabled { if !filter.Enabled {
continue continue