1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00
goreleaser/internal
Eng Zer Jun 37e3fdee55
refactor(tmpl): avoid unnecessary byte/string conversion (#4356)
We can use `(*regexp.Regexp).MatchString` instead of
`(*regexp.Regexp).Match([]byte(...))` to avoid unnecessary `[]byte`
conversions and reduce allocations. A one-line change for free
performance gain.

Benchmark:

```go
func BenchmarkMatch(b *testing.B) {
	for i := 0; i < b.N; i++ {
		if match := envOnlyRe.Match([]byte("{{ .Env.FOO }}")); !match {
			b.Fail()
		}
	}
}

func BenchmarkMatchString(b *testing.B) {
	for i := 0; i < b.N; i++ {
		if match := envOnlyRe.MatchString("{{ .Env.FOO }}"); !match {
			b.Fail()
		}
	}
}
```

Result:

```
goos: linux
goarch: amd64
pkg: github.com/goreleaser/goreleaser/internal/tmpl cpu: AMD Ryzen 7 PRO 4750U with Radeon Graphics
BenchmarkMatch-16          	 4320873	       381.2 ns/op	      16 B/op	       1 allocs/op
BenchmarkMatchString-16    	 5973543	       203.9 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	github.com/goreleaser/goreleaser/internal/tmpl	3.366s
```

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2023-10-10 09:54:44 -03:00
..
archivefiles refactor: add function to apply template multiple times (#4158) 2023-06-30 14:46:53 -03:00
artifact test: fix 2023-08-07 12:11:10 +00:00
builders feat: support WASI (#4230) 2023-09-02 14:43:07 -03:00
client refactor: improve ssh key gen on tests 2023-10-06 14:16:58 +00:00
commitauthor test: testctx pkg (#3807) 2023-03-02 00:01:11 -03:00
deprecate feat: improve output (#4206) 2023-07-25 08:26:44 -03:00
exec feat: improve template error handling (#4256) 2023-08-24 22:06:12 -03:00
extrafiles feat: improve template error handling (#4256) 2023-08-24 22:06:12 -03:00
gio refactor: gio.Chtimes (#4191) 2023-07-15 16:33:40 -03:00
git fix: git.ignore_tags not working (#4322) 2023-09-23 02:37:48 -03:00
golden feat: winget support (#4081) 2023-06-14 23:59:55 -03:00
http feat: remove deprecated replacements (#4075) 2023-06-06 11:46:02 -03:00
ids chore: gofumpt & lint (#2190) 2021-04-25 14:20:49 -03:00
logext feat: improve output (#4206) 2023-07-25 08:26:44 -03:00
middleware feat: continue on error (#4127) 2023-06-20 09:33:59 -03:00
pipe refactor: improve ssh key gen on tests 2023-10-06 14:16:58 +00:00
pipeline fix: snapshot should run before before hooks (#4250) 2023-08-15 10:24:53 -03:00
semerrgroup style: spelling and grammar fixes (#4069) 2023-06-05 13:08:57 -03:00
shell feat: improve output (#3966) 2023-05-02 09:06:35 -03:00
skips fix(skips): print all steps that will be skipped (#4319) 2023-09-20 13:15:32 -03:00
static fix: improve example config used in init 2023-08-16 13:52:42 +00:00
testctx refactor: --skip=item (#4272) 2023-09-16 17:01:20 -03:00
testlib refactor: improve ssh key gen on tests 2023-10-06 14:16:58 +00:00
tmpl refactor(tmpl): avoid unnecessary byte/string conversion (#4356) 2023-10-10 09:54:44 -03:00
yaml feat(yaml): upgraded from yaml.v2 to yaml.v3 (#3004) 2022-03-29 14:00:53 -03:00