Skip to content

Commit 16796af

Browse files
mvdanbradfitz
authored andcommitted
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í <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 2ae793e commit 16796af

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/cmd/go/internal/modconv/dep.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ package modconv
66

77
import (
88
"fmt"
9+
"internal/lazyregexp"
910
"net/url"
1011
"path"
11-
"regexp"
1212
"strconv"
1313
"strings"
1414

@@ -96,7 +96,7 @@ func ParseGopkgLock(file string, data []byte) (*modfile.File, error) {
9696
return mf, nil
9797
}
9898

99-
var scpSyntaxReg = regexp.MustCompile(`^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.*)$`)
99+
var scpSyntaxReg = lazyregexp.New(`^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.*)$`)
100100

101101
func decodeSource(source string) (string, error) {
102102
var u *url.URL

src/cmd/go/internal/sumweb/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ package sumweb
77

88
import (
99
"context"
10+
"internal/lazyregexp"
1011
"net/http"
1112
"os"
12-
"regexp"
1313
"strings"
1414

1515
"cmd/go/internal/tlog"
@@ -59,7 +59,7 @@ var Paths = []string{
5959
"/tile/",
6060
}
6161

62-
var modVerRE = regexp.MustCompile(`^[^@]+@v[0-9]+\.[0-9]+\.[0-9]+(-[^@]*)?(\+incompatible)?$`)
62+
var modVerRE = lazyregexp.New(`^[^@]+@v[0-9]+\.[0-9]+\.[0-9]+(-[^@]*)?(\+incompatible)?$`)
6363

6464
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
6565
ctx, err := h.Server.NewContext(r)

0 commit comments

Comments
 (0)