From 16796afc35de049a89da42efaad1593c26a96392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 30 May 2019 10:23:23 +0100 Subject: [PATCH] cmd/go: add two more uses of lazyregexp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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í TryBot-Result: Gobot Gobot Reviewed-by: Bryan C. Mills Reviewed-by: Brad Fitzpatrick --- src/cmd/go/internal/modconv/dep.go | 4 ++-- src/cmd/go/internal/sumweb/server.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cmd/go/internal/modconv/dep.go b/src/cmd/go/internal/modconv/dep.go index f4333001716..ccd1fc7b759 100644 --- a/src/cmd/go/internal/modconv/dep.go +++ b/src/cmd/go/internal/modconv/dep.go @@ -6,9 +6,9 @@ package modconv import ( "fmt" + "internal/lazyregexp" "net/url" "path" - "regexp" "strconv" "strings" @@ -96,7 +96,7 @@ func ParseGopkgLock(file string, data []byte) (*modfile.File, error) { 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) { var u *url.URL diff --git a/src/cmd/go/internal/sumweb/server.go b/src/cmd/go/internal/sumweb/server.go index 4619e9719b8..5050805f873 100644 --- a/src/cmd/go/internal/sumweb/server.go +++ b/src/cmd/go/internal/sumweb/server.go @@ -7,9 +7,9 @@ package sumweb import ( "context" + "internal/lazyregexp" "net/http" "os" - "regexp" "strings" "cmd/go/internal/tlog" @@ -59,7 +59,7 @@ var Paths = []string{ "/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) { ctx, err := h.Server.NewContext(r)