0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-30 22:34:15 -05:00

caddyfile: Switch to slices.Equal for better performance (#6061)

This commit is contained in:
bbaa 2024-01-25 22:46:08 +08:00 committed by GitHub
parent e965b111cd
commit 7c48b5fdbb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,6 +18,8 @@ import (
"bytes" "bytes"
"io" "io"
"unicode" "unicode"
"golang.org/x/exp/slices"
) )
// Format formats the input Caddyfile to a standard, nice-looking // Format formats the input Caddyfile to a standard, nice-looking
@ -128,7 +130,7 @@ func Format(input []byte) []byte {
heredocClosingMarker = heredocClosingMarker[1:] heredocClosingMarker = heredocClosingMarker[1:]
} }
// check if we're done // check if we're done
if string(heredocClosingMarker) == string(heredocMarker) { if slices.Equal(heredocClosingMarker, heredocMarker) {
heredocMarker = nil heredocMarker = nil
heredocClosingMarker = nil heredocClosingMarker = nil
heredoc = heredocClosed heredoc = heredocClosed