From 73442f806a9cf07e9e44b4332d1ce8cc6138b5e6 Mon Sep 17 00:00:00 2001 From: Harm Aarts Date: Thu, 5 Dec 2013 14:08:41 +0100 Subject: [PATCH] Makes atom replace channels and items, thus making it stateless --- atom.go | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/atom.go b/atom.go index ccbe786..4982030 100644 --- a/atom.go +++ b/atom.go @@ -6,32 +6,15 @@ func (this *Feed) readAtom(doc *xmlx.Document) (err error) { ns := "http://www.w3.org/2005/Atom" channels := doc.SelectNodes(ns, "feed") - getChan := func(id, title string) *Channel { - for _, c := range this.Channels { - switch { - case len(id) > 0: - if c.Id == id { - return c - } - case len(title) > 0: - if c.Title == title { - return c - } - } - } - return nil - } - + var foundChannels []*Channel var ch *Channel var i *Item var tn *xmlx.Node var list []*xmlx.Node for _, node := range channels { - if ch = getChan(node.S(ns, "id"), node.S(ns, "title")); ch == nil { - ch = new(Channel) - this.Channels = append(this.Channels, ch) - } + ch = new(Channel) + foundChannels = append(foundChannels, ch) ch.Title = node.S(ns, "title") ch.LastBuildDate = node.S(ns, "updated") @@ -121,5 +104,6 @@ func (this *Feed) readAtom(doc *xmlx.Document) (err error) { this.itemhandler(this, ch, ch.Items[itemcount:]) } } + this.Channels = foundChannels return }