From d34be9cc97c284b49886b1e8e7bf43a64f6e0bdf Mon Sep 17 00:00:00 2001 From: "Diogo Franco (Kovensky)" Date: Mon, 15 Jul 2013 01:26:58 -0300 Subject: [PATCH] anidb: Add missing loop 'break's to EpisodeByEID Without the breaks, it's would be possible to query for an Anime with AID 0, a clear waste of time. Also move the 'ok = false' assignment closer to where it's documented. --- episodecache.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/episodecache.go b/episodecache.go index 4d8fa7e..67d12b0 100644 --- a/episodecache.go +++ b/episodecache.go @@ -90,10 +90,13 @@ func (adb *AniDB) EpisodeByID(eid EID) <-chan *Episode { if id, err := strconv.ParseInt(parts[1], 10, 32); err == nil { ok = true aid = AID(id) + } else { + break } } else if reply.Code() == 340 { cache.MarkInvalid(keys...) cache.Delete(keys...) // deleted EID? + break } else { break } @@ -106,8 +109,6 @@ func (adb *AniDB) EpisodeByID(eid EID) <-chan *Episode { e = ep break } else { - ok = false - // check to see if we looked in the right AID found := false if a != nil { @@ -124,6 +125,7 @@ func (adb *AniDB) EpisodeByID(eid EID) <-chan *Episode { break } else { // otherwise, the EID<->AID map broke + ok = false cache.Delete("aid", "by-eid", eid) } } -- 2.44.0