]> git.lizzy.rs Git - go-anidb.git/commitdiff
anidb: Add missing loop 'break's to EpisodeByEID
authorDiogo Franco (Kovensky) <diogomfranco@gmail.com>
Mon, 15 Jul 2013 04:26:58 +0000 (01:26 -0300)
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>
Mon, 15 Jul 2013 04:26:58 +0000 (01:26 -0300)
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

index 4d8fa7e87aca36ea2a3ec6c37f9525cc46fcfe90..67d12b0fefaab471f407d2cbca53313987a2a447 100644 (file)
@@ -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)
                                }
                        }