func (m MatchHost) Provision(_ caddy.Context) error {
	// check for duplicates; they are nonsensical and reduce efficiency
	// (we could just remove them, but the user should know their config is erroneous)
	seen := make(map[string]int)
	for i, h := range m {
		h = strings.ToLower(h)
		if firstI, ok := seen[h]; ok {
			return fmt.Errorf("host at index %d is repeated at index %d: %s", firstI, i, h)
		}
		seen[h] = i
	}

	if m.large() {
		// sort the slice lexicographically, grouping "fuzzy" entries (wildcards and placeholders)
		// at the front of the list; this allows us to use binary search for exact matches, which
		// we have seen from experience is the most common kind of value in large lists; and any
		// other kinds of values (wildcards and placeholders) are grouped in front so the linear
		// search should find a match fairly quickly
		sort.Slice(m, func(i, j int) bool {
			iInexact, jInexact := m.fuzzy(m[i]), m.fuzzy(m[j])
			if iInexact && !jInexact {
				return true
			}
			if !iInexact && jInexact {
				return false
			}
			return m[i] < m[j]
		})
	}

	return nil
}
// Provision sets up and validates m, including making it more efficient for large lists.
Provision sets up and validates m, including making it more efficient for large lists.
// Provision sets up and validates m including making it more efficient for large lists .
func (m MatchHost) Provision(_ caddy.Context) error {
	seen := make(map[string]int)
	for i, h := range m {
		h = strings.ToLower(h)
		if firstI, ok := seen[h]; ok {
			return fmt.Errorf("host at index %d is repeated at index %d: %s", firstI, i, h)
		}
		seen[h] = i
	}
	if m.large() {
		sort.Slice(m, func(i, j int) bool {
			iInexact, jInexact := m.fuzzy(m[i]), m.fuzzy(m[j])
			if iInexact && !jInexact {
				return true
			}
			if !iInexact && jInexact {
				return false
			}
			return m[i] < m[j]
		})
	}
	return nil
}
func ( m MatchHost ) Provision ( _ caddy . Context ) error { seen := make ( map [ string ] int ) for i , h := range m { h = strings . ToLower ( h ) if firstI , ok := seen [ h ] ; ok { return fmt . Errorf ( " " , firstI , i , h ) } seen [ h ] = i } if m . large ( ) { sort . Slice ( m , func ( i , j int ) bool { iInexact , jInexact := m . fuzzy ( m [ i ] ) , m . fuzzy ( m [ j ] ) if iInexact && ! jInexact { return true } if ! iInexact && jInexact { return false } return m [ i ] < m [ j ] } ) } return nil }
Provision sets up and validates m, including making it more efficient for large lists.
Provision sets up and validates m including making it more efficient for large lists .
// check for duplicates; they are nonsensical and reduce efficiency // (we could just remove them, but the user should know their config is erroneous) // sort the slice lexicographically, grouping "fuzzy" entries (wildcards and placeholders) // at the front of the list; this allows us to use binary search for exact matches, which // we have seen from experience is the most common kind of value in large lists; and any // other kinds of values (wildcards and placeholders) are grouped in front so the linear // search should find a match fairly quickly