Skip to content

Commit

Permalink
Update Optimize performance
Browse files Browse the repository at this point in the history
  • Loading branch information
leetaifook committed Jan 2, 2013
1 parent 1b9b1f1 commit dda6bec
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions urlmanage/urlmanage.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ func (u *UrlManage) clearRule() {
}

func (u *UrlManage) loadRule(rules string) {
u.mutex.RLock()
defer u.mutex.RUnlock()
for _, r := range strings.Split(rules, "\n") {
u.AddRule(r)
}
Expand All @@ -216,10 +214,11 @@ func (u *UrlManage) AddRule(r string) {
func (u *UrlManage) ReWrite(rw http.ResponseWriter, req *http.Request) string {
out := req.URL.String()
u.mutex.RLock()
if u.manage {
manage := u.manage
u.mutex.RUnlock()
if manage {
out = u.doRule(rw, req)
}
u.mutex.RUnlock()

return out
}
Expand Down

0 comments on commit dda6bec

Please sign in to comment.