Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aa0f078

Browse files
committedJan 12, 2025··
refactor: refactor and optimize exclusion handling logic
- Preallocate map with the length of extensions in `NewExcludedExtensions` - Use `ExcludedPathesRegexs` type for the result slice in `NewExcludedPathesRegexs` Signed-off-by: appleboy <appleboy.tw@gmail.com>
1 parent fa26419 commit aa0f078

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

Diff for: ‎options.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func WithDecompressFn(decompressFn func(c *gin.Context)) Option {
5555
type ExcludedExtensions map[string]struct{}
5656

5757
func NewExcludedExtensions(extensions []string) ExcludedExtensions {
58-
res := make(ExcludedExtensions)
58+
res := make(ExcludedExtensions, len(extensions))
5959
for _, e := range extensions {
6060
res[e] = struct{}{}
6161
}
@@ -85,7 +85,7 @@ func (e ExcludedPaths) Contains(requestURI string) bool {
8585
type ExcludedPathesRegexs []*regexp.Regexp
8686

8787
func NewExcludedPathesRegexs(regexs []string) ExcludedPathesRegexs {
88-
result := make([]*regexp.Regexp, len(regexs))
88+
result := make(ExcludedPathesRegexs, len(regexs))
8989
for i, reg := range regexs {
9090
result[i] = regexp.MustCompile(reg)
9191
}

0 commit comments

Comments
 (0)
Please sign in to comment.