Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve IsMethod #1088

Merged
merged 5 commits into from
Sep 6, 2021
Merged

feat: improve IsMethod #1088

merged 5 commits into from
Sep 6, 2021

Conversation

tylitianrui
Copy link
Contributor

improve IsMethod i.e IsPostIsGet and so on.

benchmark

  • old
goos: linux
goarch: amd64
pkg: github.com/valyala/fasthttp
cpu: Intel(R) Xeon(R) Platinum 8255C CPU @ 2.50GHz
BenchmarkRequestHeaderIsPost-2          559623241                2.003 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          604524886                1.992 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          601059054                2.015 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          605856414                2.006 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          606804846                1.981 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          608144640                1.984 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          606334010                2.000 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          606591694                2.001 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          606142994                2.007 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          602808153                1.974 ns/op           0 B/op          0 allocs/op
PASS
ok      github.com/valyala/fasthttp     14.092s
  • new
goos: linux
goarch: amd64
pkg: github.com/valyala/fasthttp
cpu: Intel(R) Xeon(R) Platinum 8255C CPU @ 2.50GHz
BenchmarkRequestHeaderIsPost-2          982056084                1.123 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          1000000000               1.127 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          1000000000               1.121 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          1000000000               1.122 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          1000000000               1.114 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          1000000000               1.132 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          1000000000               1.114 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          1000000000               1.115 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          1000000000               1.111 ns/op           0 B/op          0 allocs/op
BenchmarkRequestHeaderIsPost-2          1000000000               1.133 ns/op           0 B/op          0 allocs/op
PASS
ok      github.com/valyala/fasthttp     12.406s

req.IsPatch()
}
})
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the methods do the same so just a benchmark for IsGet is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx. i will change it.

strings.go Outdated
strConnect = []byte(MethodConnect) //nolint:unused
strOptions = []byte(MethodOptions) //nolint:unused
strTrace = []byte(MethodTrace) //nolint:unused
strPatch = []byte(MethodPatch) //nolint:unused
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they are unused and unexported you can remove them.

client.go Outdated Show resolved Hide resolved
Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
@@ -950,7 +950,7 @@ var clientURLResponseChPool sync.Pool

func clientPostURL(dst []byte, url string, postArgs *Args, c clientDoer) (statusCode int, body []byte, err error) {
req := AcquireRequest()
req.Header.SetMethodBytes(strPost)
req.Header.SetMethod(MethodPost)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IT IS BETTER THAN MINE. THX

@erikdubbelboer erikdubbelboer merged commit f0a2189 into valyala:master Sep 6, 2021
@erikdubbelboer
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants