Commit 16796afc authored by Daniel Martí's avatar Daniel Martí Committed by Brad Fitzpatrick

cmd/go: add two more uses of lazyregexp

A couple of regexp.MustCompile globals have made their way in since we
introduced this package for cmd/go.

Convert the declarations. It's just two of them, so the cmd/go exec
benchmark isn't affected noticeably.

Change-Id: Ibd0615c99b6a049124a952c59978fd714c1b9615
Reviewed-on: https://go-review.googlesource.com/c/go/+/179358
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 2ae793ed
...@@ -6,9 +6,9 @@ package modconv ...@@ -6,9 +6,9 @@ package modconv
import ( import (
"fmt" "fmt"
"internal/lazyregexp"
"net/url" "net/url"
"path" "path"
"regexp"
"strconv" "strconv"
"strings" "strings"
...@@ -96,7 +96,7 @@ func ParseGopkgLock(file string, data []byte) (*modfile.File, error) { ...@@ -96,7 +96,7 @@ func ParseGopkgLock(file string, data []byte) (*modfile.File, error) {
return mf, nil return mf, nil
} }
var scpSyntaxReg = regexp.MustCompile(`^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.*)$`) var scpSyntaxReg = lazyregexp.New(`^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.*)$`)
func decodeSource(source string) (string, error) { func decodeSource(source string) (string, error) {
var u *url.URL var u *url.URL
......
...@@ -7,9 +7,9 @@ package sumweb ...@@ -7,9 +7,9 @@ package sumweb
import ( import (
"context" "context"
"internal/lazyregexp"
"net/http" "net/http"
"os" "os"
"regexp"
"strings" "strings"
"cmd/go/internal/tlog" "cmd/go/internal/tlog"
...@@ -59,7 +59,7 @@ var Paths = []string{ ...@@ -59,7 +59,7 @@ var Paths = []string{
"/tile/", "/tile/",
} }
var modVerRE = regexp.MustCompile(`^[^@]+@v[0-9]+\.[0-9]+\.[0-9]+(-[^@]*)?(\+incompatible)?$`) var modVerRE = lazyregexp.New(`^[^@]+@v[0-9]+\.[0-9]+\.[0-9]+(-[^@]*)?(\+incompatible)?$`)
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx, err := h.Server.NewContext(r) ctx, err := h.Server.NewContext(r)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment