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)
|
co.SetReverseOSMapEnum(reverseOSMapEnum)
|
||||||
c.Chrome = agentMapEnum["chrome"]
|
c.Chrome = agentMapEnum["chrome"]
|
||||||
c.Firefox = agentMapEnum["firefox"]
|
c.Firefox = agentMapEnum["firefox"]
|
||||||
|
ame := agentMapEnum
|
||||||
c.SimpleBots = []int{
|
c.SimpleBots = []int{
|
||||||
agentMapEnum["semrush"],
|
ame["semrush"],
|
||||||
agentMapEnum["ahrefs"],
|
ame["ahrefs"],
|
||||||
agentMapEnum["python"],
|
ame["python"],
|
||||||
agentMapEnum["go"],
|
ame["go"],
|
||||||
agentMapEnum["curl"],
|
ame["curl"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1013,17 +1014,11 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
req.URL.Path = c.Config.DefaultPath
|
req.URL.Path = c.Config.DefaultPath
|
||||||
}
|
}
|
||||||
//log.Print("URL.Path: ", req.URL.Path)
|
//log.Print("URL.Path: ", req.URL.Path)
|
||||||
|
prefix := req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1]
|
||||||
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]
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Use the same hook table as downstream
|
// TODO: Use the same hook table as downstream
|
||||||
hTbl := c.GetHookTable()
|
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 {
|
if skip || ferr != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1052,7 +1047,6 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
if !c.Config.DisableAnalytics {
|
if !c.Config.DisableAnalytics {
|
||||||
co.RouteViewCounter.Bump(167)
|
co.RouteViewCounter.Bump(167)
|
||||||
}
|
}
|
||||||
req.URL.Path += extraData
|
|
||||||
routes.StaticFile(w, req)
|
routes.StaticFile(w, req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1064,6 +1058,12 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
r.requestLogger.Print("before PreRoute")
|
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 {
|
/*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")
|
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)
|
co.SetReverseOSMapEnum(reverseOSMapEnum)
|
||||||
c.Chrome = agentMapEnum["chrome"]
|
c.Chrome = agentMapEnum["chrome"]
|
||||||
c.Firefox = agentMapEnum["firefox"]
|
c.Firefox = agentMapEnum["firefox"]
|
||||||
|
ame := agentMapEnum
|
||||||
c.SimpleBots = []int{
|
c.SimpleBots = []int{
|
||||||
agentMapEnum["semrush"],
|
ame["semrush"],
|
||||||
agentMapEnum["ahrefs"],
|
ame["ahrefs"],
|
||||||
agentMapEnum["python"],
|
ame["python"],
|
||||||
agentMapEnum["go"],
|
ame["go"],
|
||||||
agentMapEnum["curl"],
|
ame["curl"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,17 +692,11 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
req.URL.Path = c.Config.DefaultPath
|
req.URL.Path = c.Config.DefaultPath
|
||||||
}
|
}
|
||||||
//log.Print("URL.Path: ", req.URL.Path)
|
//log.Print("URL.Path: ", req.URL.Path)
|
||||||
|
prefix := req.URL.Path[0:strings.IndexByte(req.URL.Path[1:],'/') + 1]
|
||||||
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]
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Use the same hook table as downstream
|
// TODO: Use the same hook table as downstream
|
||||||
hTbl := c.GetHookTable()
|
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 {
|
if skip || ferr != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -730,7 +725,6 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
if !c.Config.DisableAnalytics {
|
if !c.Config.DisableAnalytics {
|
||||||
co.RouteViewCounter.Bump({{index .AllRouteMap "routes.StaticFile"}})
|
co.RouteViewCounter.Bump({{index .AllRouteMap "routes.StaticFile"}})
|
||||||
}
|
}
|
||||||
req.URL.Path += extraData
|
|
||||||
routes.StaticFile(w, req)
|
routes.StaticFile(w, req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -742,6 +736,12 @@ func (r *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
r.requestLogger.Print("before PreRoute")
|
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 {
|
/*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")
|
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