mirror of https://github.com/miniflux/v2.git
Preallocate memory when exporting to OPML
This should marginally increase performance when export a large amount of feeds to OPML.
This commit is contained in:
parent
8d80e9103f
commit
3339d9d3d7
|
@ -23,7 +23,7 @@ func (h *Handler) Export(userID int64) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
var subscriptions SubcriptionList
|
subscriptions := make(SubcriptionList, 0, len(feeds))
|
||||||
for _, feed := range feeds {
|
for _, feed := range feeds {
|
||||||
subscriptions = append(subscriptions, &Subcription{
|
subscriptions = append(subscriptions, &Subcription{
|
||||||
Title: feed.Title,
|
Title: feed.Title,
|
||||||
|
|
|
@ -38,14 +38,14 @@ func convertSubscriptionsToOPML(subscriptions SubcriptionList) *opmlDocument {
|
||||||
opmlDocument.Header.DateCreated = time.Now().Format("Mon, 02 Jan 2006 15:04:05 MST")
|
opmlDocument.Header.DateCreated = time.Now().Format("Mon, 02 Jan 2006 15:04:05 MST")
|
||||||
|
|
||||||
groupedSubs := groupSubscriptionsByFeed(subscriptions)
|
groupedSubs := groupSubscriptionsByFeed(subscriptions)
|
||||||
var categories []string
|
categories := make([]string, 0, len(groupedSubs))
|
||||||
for k := range groupedSubs {
|
for k := range groupedSubs {
|
||||||
categories = append(categories, k)
|
categories = append(categories, k)
|
||||||
}
|
}
|
||||||
sort.Strings(categories)
|
sort.Strings(categories)
|
||||||
|
|
||||||
for _, categoryName := range categories {
|
for _, categoryName := range categories {
|
||||||
category := opmlOutline{Text: categoryName}
|
category := opmlOutline{Text: categoryName, Outlines: make(opmlOutlineCollection, 0, len(groupedSubs[categoryName]))}
|
||||||
for _, subscription := range groupedSubs[categoryName] {
|
for _, subscription := range groupedSubs[categoryName] {
|
||||||
category.Outlines = append(category.Outlines, opmlOutline{
|
category.Outlines = append(category.Outlines, opmlOutline{
|
||||||
Title: subscription.Title,
|
Title: subscription.Title,
|
||||||
|
|
Loading…
Reference in New Issue