Remove redundant nil check (#2194)

From the Go docs:

  "If the map is nil, the number of iterations is 0." [1]

Therefore, an additional nil check for before the loop is unnecessary.

[1]: https://go.dev/ref/spec#For_range

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun 2023-08-22 01:12:22 +08:00 committed by GitHub
parent 9f53d15133
commit 6a449876e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 16 deletions

View File

@ -244,7 +244,6 @@ func (w *ResponseRecorder) CopyTo(res ResponseWriter) {
}
// append the headers
if w.headers != nil {
for k, values := range w.headers {
for _, v := range values {
if to.headers.Get(v) == "" {
@ -252,7 +251,6 @@ func (w *ResponseRecorder) CopyTo(res ResponseWriter) {
}
}
}
}
// append the body
if len(w.chunks) > 0 {

View File

@ -319,7 +319,6 @@ func (w *responseWriter) CopyTo(to ResponseWriter) {
}
// append the headers
if w.Header() != nil {
for k, values := range w.Header() {
for _, v := range values {
if to.Header().Get(v) == "" {
@ -327,7 +326,6 @@ func (w *responseWriter) CopyTo(to ResponseWriter) {
}
}
}
}
// the body is not copied, this writer doesn't support recording
}

View File

@ -282,12 +282,10 @@ func (s *JetEngine) initSet() {
}
s.Set = jet.NewSet(s.loader, opts...)
if s.vars != nil {
for key, value := range s.vars {
s.Set.AddGlobal(key, value)
}
}
}
s.mu.Unlock()
}