From 5b2558bf9231df0805cb2b4167969ff283af2074 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 26 Feb 2024 17:07:28 +0100 Subject: [PATCH] Miscellaneous improvements to internal/reader/subscription/finder.go - Surface `localizedError` in FindSubscriptionsFromWellKnownURLs via slog - Use an inline declaration for new subscriptions, like done elsewhere in the file, if only for consistency's sake - Preallocate the `subscriptions` slice when using an RSS-bridge, it's a good practise, and it might even marginally improve performances when adding __a lot__ of feeds via an rss-bridge instance, wooo! --- internal/reader/subscription/finder.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/reader/subscription/finder.go b/internal/reader/subscription/finder.go index c1f164c2..ebbf425b 100644 --- a/internal/reader/subscription/finder.go +++ b/internal/reader/subscription/finder.go @@ -235,14 +235,15 @@ func (f *SubscriptionFinder) FindSubscriptionsFromWellKnownURLs(websiteURL strin defer responseHandler.Close() if localizedError := responseHandler.LocalizedError(); localizedError != nil { + slog.Debug("Unable to subscribe", slog.String("fullURL", fullURL), slog.Any("error", localizedError.Error())) continue } - subscription := new(Subscription) - subscription.Type = kind - subscription.Title = fullURL - subscription.URL = fullURL - subscriptions = append(subscriptions, subscription) + subscriptions = append(subscriptions, &Subscription{ + Type: kind, + Title: fullURL, + URL: fullURL, + }) } } @@ -270,7 +271,7 @@ func (f *SubscriptionFinder) FindSubscriptionsFromRSSBridge(websiteURL, rssBridg return nil, nil } - var subscriptions Subscriptions + subscriptions := make(Subscriptions, 0, len(bridges)) for _, bridge := range bridges { subscriptions = append(subscriptions, &Subscription{ Title: bridge.BridgeMeta.Name,