Skip to content

Commit

Permalink
mmcdole#151: Atom parser: Avoid superfluous intermediate variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Necoro committed Oct 23, 2021
1 parent ceade53 commit f3e5457
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions atom/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit f3e5457

Please sign in to comment.