From f3e5457e1a0df6135d89ae2486276a303bd89fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 5 Aug 2020 23:27:42 +0200 Subject: [PATCH] #151: Atom parser: Avoid superfluous intermediate variables --- atom/parser.go | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/atom/parser.go b/atom/parser.go index 000ace6e..fc61c255 100644 --- a/atom/parser.go +++ b/atom/parser.go @@ -214,10 +214,6 @@ func (ap *Parser) parseEntry(p *xpp.XMLPullParser) (*Entry, error) { } entry := &Entry{} - contributors := []*Person{} - authors := []*Person{} - categories := []*Category{} - links := []*Link{} extensions := ext.Extensions{} for { @@ -288,25 +284,25 @@ func (ap *Parser) parseEntry(p *xpp.XMLPullParser) (*Entry, error) { if err != nil { return nil, err } - contributors = append(contributors, result) + entry.Contributors = append(entry.Contributors, result) } else if name == "author" { result, err := ap.parsePerson("author", p) if err != nil { return nil, err } - authors = append(authors, result) + entry.Authors = append(entry.Authors, result) } else if name == "category" { result, err := ap.parseCategory(p) if err != nil { return nil, err } - categories = append(categories, result) + entry.Categories = append(entry.Categories, result) } else if name == "link" { result, err := ap.parseLink(p) if err != nil { return nil, err } - links = append(links, result) + entry.Links = append(entry.Links, result) } else if name == "published" || name == "issued" { result, err := ap.parseAtomText(p) @@ -334,22 +330,6 @@ func (ap *Parser) parseEntry(p *xpp.XMLPullParser) (*Entry, error) { } } - if len(categories) > 0 { - entry.Categories = categories - } - - if len(authors) > 0 { - entry.Authors = authors - } - - if len(links) > 0 { - entry.Links = links - } - - if len(contributors) > 0 { - entry.Contributors = contributors - } - if len(extensions) > 0 { entry.Extensions = extensions }