mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
remove goroutines from template parsing.
fix up one usage to take advantage. R=rsc CC=go-dev http://go/go-review/1018023
This commit is contained in:
parent
f32cde88b6
commit
236a9de93f
2 changed files with 77 additions and 42 deletions
|
|
@ -12,7 +12,6 @@ package rpc
|
|||
import (
|
||||
"fmt";
|
||||
"http";
|
||||
"os";
|
||||
"sort";
|
||||
"template";
|
||||
)
|
||||
|
|
@ -37,7 +36,7 @@ const debugText = `<html>
|
|||
</body>
|
||||
</html>`
|
||||
|
||||
var debug *template.Template
|
||||
var debug = template.MustParse(debugText, nil)
|
||||
|
||||
type debugMethod struct {
|
||||
m *methodType;
|
||||
|
|
@ -76,14 +75,6 @@ func (m methodArray) Swap(i, j int) {
|
|||
|
||||
// Runs at /debug/rpc
|
||||
func debugHTTP(c *http.Conn, req *http.Request) {
|
||||
var err os.Error;
|
||||
if debug == nil {
|
||||
debug, err = template.Parse(debugText, nil);
|
||||
if err != nil {
|
||||
fmt.Fprintln(c, "rpc can't create debug HTML template:", err.String());
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Build a sorted version of the data.
|
||||
var services = make(serviceArray, len(server.serviceMap));
|
||||
i := 0;
|
||||
|
|
@ -100,7 +91,7 @@ func debugHTTP(c *http.Conn, req *http.Request) {
|
|||
}
|
||||
server.Unlock();
|
||||
sort.Sort(services);
|
||||
err = debug.Execute(services, c);
|
||||
err := debug.Execute(services, c);
|
||||
if err != nil {
|
||||
fmt.Fprintln(c, "rpc: error executing template:", err.String());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue