Skip to content

Commit

Permalink
modified SpiderSpecies.Add()
Browse files Browse the repository at this point in the history
  • Loading branch information
andeya committed Oct 11, 2016
1 parent 5c9082a commit 918bb00
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/spider/species.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ var Species = &SpiderSpecies{

// 向蜘蛛种类清单添加新种类
func (self *SpiderSpecies) Add(sp *Spider) *Spider {
for i, name := 2, sp.Name; true; i++ {
name := sp.Name
for i := 2; true; i++ {
if _, ok := self.hash[name]; !ok {
sp.Name = name
self.hash[sp.Name] = sp
break
}
name = fmt.Sprintf("%s(%d)", sp.Name, i)
}
sp.Name = name
self.list = append(self.list, sp)
return sp
}
Expand Down

0 comments on commit 918bb00

Please sign in to comment.