Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
ixqbar committed Jul 27, 2017
1 parent b42f6b3 commit be254ea
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/xqb/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ func (this *SearchRedisHandle) Init(db int) error {
this.Lock()
defer this.Unlock()

if this.jieba != nil {
if _, ok := this.jieba[db]; ok {
return nil
}
if _, ok := this.jieba[db]; ok {
return nil
}

dictPath := path.Join(jiebaXmlConfig.DictPath, fmt.Sprintf("%d", db))
Expand All @@ -62,10 +60,6 @@ func (this *SearchRedisHandle) Init(db int) error {
}
}

if this.jieba == nil {
this.jieba = make(map[int]*gojieba.Jieba, 0)
}

this.jieba[db] = gojieba.NewJieba(dictPaths[0], dictPaths[1], dictPaths[2], dictPaths[3], dictPaths[4])

return nil
Expand Down Expand Up @@ -150,7 +144,7 @@ func (this *SearchRedisHandle) AddWord(client *redis.Client, word string) (strin

func Run() {
searcher := &SearchRedisHandle{
jieba: nil,
jieba: make(map[int]*gojieba.Jieba, 0),
}

searcher.SetShield("Init")
Expand Down

0 comments on commit be254ea

Please sign in to comment.