From 3b19bd77f678c3471aed6856d126f9de54dbfbeb Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 26 Sep 2017 12:54:13 +0800 Subject: [PATCH] remove unused count variables --- engine_group.go | 2 +- engine_group_policy.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/engine_group.go b/engine_group.go index dd1e6380..5e659aaf 100644 --- a/engine_group.go +++ b/engine_group.go @@ -17,7 +17,7 @@ type EngineGroup struct { policy GroupPolicy } -func NewGroup(args1 interface{}, args2 interface{}, policies ...GroupPolicy) (*EngineGroup, error) { +func NewEngineGroup(args1 interface{}, args2 interface{}, policies ...GroupPolicy) (*EngineGroup, error) { var eg EngineGroup if len(policies) > 0 { eg.policy = policies[0] diff --git a/engine_group_policy.go b/engine_group_policy.go index 73b1226f..c3e528ad 100644 --- a/engine_group_policy.go +++ b/engine_group_policy.go @@ -68,16 +68,17 @@ func NewRoundRobinPolicy() *RoundRobinPolicy { } func (policy *RoundRobinPolicy) Slave(g *EngineGroup) *Engine { + var slaves = g.Slaves() var pos int policy.lock.Lock() policy.pos++ - if policy.pos >= len(g.Slaves()) { + if policy.pos >= len(slaves) { policy.pos = 0 } pos = policy.pos policy.lock.Unlock() - return g.Slaves()[pos] + return slaves[pos] } type WeightRoundRobinPolicy struct {