1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-16 18:01:37 +00:00

refactor(opml): reduce indirections

Don't use a slice of pointers to opml items, when we can simply use a slice of
items instead. This should reduce the amount of memory allocations and the
number of indirections the GC has to process, speedup up the import process.

Note that this doesn't introduce any additional copies, as the only time a
slice of subscription is created, the items are created and inserted inline.
This commit is contained in:
jvoisin 2025-08-11 16:15:44 +02:00 committed by Frédéric Guillot
parent 8bca777a6d
commit 93fc206f42
6 changed files with 42 additions and 43 deletions

View file

@ -13,7 +13,7 @@ import (
)
// serialize returns a SubcriptionList in OPML format.
func serialize(subscriptions subcriptionList) string {
func serialize(subscriptions []subcription) string {
var b bytes.Buffer
writer := bufio.NewWriter(&b)
writer.WriteString(xml.Header)
@ -31,7 +31,7 @@ func serialize(subscriptions subcriptionList) string {
return b.String()
}
func convertSubscriptionsToOPML(subscriptions subcriptionList) *opmlDocument {
func convertSubscriptionsToOPML(subscriptions []subcription) *opmlDocument {
opmlDocument := &opmlDocument{}
opmlDocument.Version = "2.0"
opmlDocument.Header.Title = "Miniflux"
@ -62,8 +62,8 @@ func convertSubscriptionsToOPML(subscriptions subcriptionList) *opmlDocument {
return opmlDocument
}
func groupSubscriptionsByFeed(subscriptions subcriptionList) map[string]subcriptionList {
groups := make(map[string]subcriptionList)
func groupSubscriptionsByFeed(subscriptions []subcription) map[string][]subcription {
groups := make(map[string][]subcription)
for _, subscription := range subscriptions {
groups[subscription.CategoryName] = append(groups[subscription.CategoryName], subscription)