From 543a690bfdda1001f8f275122ef7bac3f0810ccc Mon Sep 17 00:00:00 2001 From: jvoisin Date: Thu, 29 Feb 2024 00:30:54 +0100 Subject: [PATCH] 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. --- internal/reader/subscription/finder.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/reader/subscription/finder.go b/internal/reader/subscription/finder.go index ebbf425b..e514a00b 100644 --- a/internal/reader/subscription/finder.go +++ b/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 }