From 807e526f05812e622b33c4bddf1300e4fac02ea9 Mon Sep 17 00:00:00 2001 From: "Diogo Franco (Kovensky)" Date: Tue, 16 Jul 2013 13:50:18 -0300 Subject: [PATCH] anidb: Simplify (*AniDB).EpisodeByID() Use (*Anime).EpisodeByEID() to search for the requested episode. --- episodecache.go | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/episodecache.go b/episodecache.go index 3c3a91e..cd2e4aa 100644 --- a/episodecache.go +++ b/episodecache.go @@ -108,32 +108,16 @@ func (adb *AniDB) EpisodeByID(eid EID) <-chan *Episode { } udpDone = true } - a := <-adb.AnimeByID(AID(aid)) // this caches episodes... - ep := eid.Episode() // ...so this is now a cache hit + a := <-adb.AnimeByID(AID(aid)) // updates the episode cache as well + ep := a.EpisodeByEID(eid) - if !ep.IsStale() { + if ep != nil { e = ep break } else { - // check to see if we looked in the right AID - found := false - if a != nil { - for _, ep := range a.Episodes { - if eid == ep.EID { - found = true - break - } - } - } - - // if found, then it's just that the anime is also stale (offline?) - if found { - break - } else { - // otherwise, the EID<->AID map broke - ok = false - cache.Delete("aid", "by-eid", eid) - } + // the EID<->AID map broke + ok = false + cache.Delete("aid", "by-eid", eid) } } intentMap.NotifyClose(e, keys...) -- 2.44.0