Skip to content

Commit

Permalink
use Index instead of Split to avoid allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
pearcedavis authored and pkieltyka committed Feb 27, 2019
1 parent 52e06e6 commit 7eb231e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions middleware/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,9 @@ func (cw *compressResponseWriter) WriteHeader(code int) {
}

// Parse the first part of the Content-Type response header.
contentType := ""
parts := strings.Split(cw.Header().Get("Content-Type"), ";")
if len(parts) > 0 {
contentType = parts[0]
contentType := cw.Header().Get("Content-Type")
if idx := strings.Index(contentType, ";"); idx >= 0 {
contentType = contentType[0:idx]
}

// Is the content type compressable?
Expand Down

0 comments on commit 7eb231e

Please sign in to comment.