Browse Source

Close resources as soon as possible, instead of using defer() in a loop

So that resources can be freed as soon as they're not used anymore, instead of
waiting for the two nested loops to finish.
jvoisin 2 years ago
parent
commit
543a690bfd
1 changed files with 3 additions and 2 deletions
  1. 3 2
      internal/reader/subscription/finder.go

+ 3 - 2
internal/reader/subscription/finder.go

@@ -232,9 +232,10 @@ func (f *SubscriptionFinder) FindSubscriptionsFromWellKnownURLs(websiteURL strin
 			f.requestBuilder.WithoutRedirects()
 
 			responseHandler := fetcher.NewResponseHandler(f.requestBuilder.ExecuteRequest(fullURL))
-			defer responseHandler.Close()
+			localizedError := responseHandler.LocalizedError()
+			responseHandler.Close()
 
-			if localizedError := responseHandler.LocalizedError(); localizedError != nil {
+			if localizedError != nil {
 				slog.Debug("Unable to subscribe", slog.String("fullURL", fullURL), slog.Any("error", localizedError.Error()))
 				continue
 			}