eliminate extraData related allocs in /s/ hot path
shorten generated simple bot bits
This commit is contained in:
parent
ade8f82af7
commit
6b7c51a604
|
@ -803,12 +803,13 @@ func init() {
|
|||
co.SetReverseOSMapEnum(reverseOSMapEnum)
|
||||
c.Chrome = agentMapEnum["chrome"]
|
||||
c.Firefox = agentMapEnum["firefox"]
|
||||
ame := agentMapEnum
|
||||
c.SimpleBots = []int{
|
||||
agentMapEnum["semrush"],
|
||||
agentMapEnum["ahrefs"],
|
||||
agentMapEnum["python"],
|
||||
agentMapEnum["go"],
|
||||
agentMapEnum["curl"],
|
||||
ame["semrush"],
|
||||
ame["ahrefs"],
|
||||
ame["python"],
|
||||
ame["go"],
|
||||
ame["curl"],
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1013,17 +1014,11 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||
req.URL.Path = c.Config.DefaultPath
|
||||
}
|
||||
//log.Print("URL.Path: ", req.URL.Path)
|
||||
|
||||
var prefix, extraData string
|
||||
prefix = req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1]
|
||||
if req.URL.Path[len(req.URL.Path) - 1] != '/' {
|
||||
extraData = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:]
|
||||
req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1]
|
||||
}
|
||||
prefix := req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1]
|
||||
|
||||
// TODO: Use the same hook table as downstream
|
||||
hTbl := c.GetHookTable()
|
||||
skip, ferr := hTbl.VhookSkippable("router_after_filters", w, req, prefix, extraData)
|
||||
skip, ferr := hTbl.VhookSkippable("router_after_filters", w, req, prefix)
|
||||
if skip || ferr != nil {
|
||||
return
|
||||
}
|
||||
|
@ -1052,7 +1047,6 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||
if !c.Config.DisableAnalytics {
|
||||
co.RouteViewCounter.Bump(167)
|
||||
}
|
||||
req.URL.Path += extraData
|
||||
routes.StaticFile(w, req)
|
||||
return
|
||||
}
|
||||
|
@ -1064,6 +1058,12 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||
r.requestLogger.Print("before PreRoute")
|
||||
}
|
||||
|
||||
var extraData string
|
||||
if req.URL.Path[len(req.URL.Path) - 1] != '/' {
|
||||
extraData = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:]
|
||||
req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1]
|
||||
}
|
||||
|
||||
/*if c.Dev.QuicPort != 0 {
|
||||
w.Header().Set("Alt-Svc", "quic=\":"+strconv.Itoa(c.Dev.QuicPort)+"\"; ma=2592000; v=\"44,43,39\", h3-23=\":"+strconv.Itoa(c.Dev.QuicPort)+"\"; ma=3600, h3-24=\":"+strconv.Itoa(c.Dev.QuicPort)+"\"; ma=3600, h2=\":443\"; ma=3600")
|
||||
}*/
|
||||
|
|
|
@ -481,12 +481,13 @@ func init() {
|
|||
co.SetReverseOSMapEnum(reverseOSMapEnum)
|
||||
c.Chrome = agentMapEnum["chrome"]
|
||||
c.Firefox = agentMapEnum["firefox"]
|
||||
ame := agentMapEnum
|
||||
c.SimpleBots = []int{
|
||||
agentMapEnum["semrush"],
|
||||
agentMapEnum["ahrefs"],
|
||||
agentMapEnum["python"],
|
||||
agentMapEnum["go"],
|
||||
agentMapEnum["curl"],
|
||||
ame["semrush"],
|
||||
ame["ahrefs"],
|
||||
ame["python"],
|
||||
ame["go"],
|
||||
ame["curl"],
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -691,17 +692,11 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||
req.URL.Path = c.Config.DefaultPath
|
||||
}
|
||||
//log.Print("URL.Path: ", req.URL.Path)
|
||||
|
||||
var prefix, extraData string
|
||||
prefix = req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1]
|
||||
if req.URL.Path[len(req.URL.Path) - 1] != '/' {
|
||||
extraData = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:]
|
||||
req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1]
|
||||
}
|
||||
prefix := req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1]
|
||||
|
||||
// TODO: Use the same hook table as downstream
|
||||
hTbl := c.GetHookTable()
|
||||
skip, ferr := hTbl.VhookSkippable("router_after_filters", w, req, prefix, extraData)
|
||||
skip, ferr := hTbl.VhookSkippable("router_after_filters", w, req, prefix)
|
||||
if skip || ferr != nil {
|
||||
return
|
||||
}
|
||||
|
@ -730,7 +725,6 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||
if !c.Config.DisableAnalytics {
|
||||
co.RouteViewCounter.Bump({{index .AllRouteMap "routes.StaticFile"}})
|
||||
}
|
||||
req.URL.Path += extraData
|
||||
routes.StaticFile(w, req)
|
||||
return
|
||||
}
|
||||
|
@ -742,6 +736,12 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||
r.requestLogger.Print("before PreRoute")
|
||||
}
|
||||
|
||||
var extraData string
|
||||
if req.URL.Path[len(req.URL.Path) - 1] != '/' {
|
||||
extraData = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:]
|
||||
req.URL.Path = req.URL.Path[:strings.LastIndexByte(req.URL.Path,'/') + 1]
|
||||
}
|
||||
|
||||
/*if c.Dev.QuicPort != 0 {
|
||||
w.Header().Set("Alt-Svc", "quic=\":"+strconv.Itoa(c.Dev.QuicPort)+"\"; ma=2592000; v=\"44,43,39\", h3-23=\":"+strconv.Itoa(c.Dev.QuicPort)+"\"; ma=3600, h3-24=\":"+strconv.Itoa(c.Dev.QuicPort)+"\"; ma=3600, h2=\":443\"; ma=3600")
|
||||
}*/
|
||||
|
|
Loading…
Reference in New Issue