Skip to content

Commit 9d723ce

Browse files
committed
perf(http): remove unused atomic.Bool
1 parent 1453732 commit 9d723ce

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

api/json_request_body.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"encoding/json"
66
"errors"
77
"io"
8-
"sync/atomic"
98
)
109

1110
type JsonRequestBody interface {
@@ -20,15 +19,15 @@ func NewJsonRequestBody(V any) JsonRequestBody {
2019
type jsonReqBody struct {
2120
v any
2221
pr *io.PipeReader
23-
closed atomic.Bool
22+
closed bool
2423
}
2524

2625
func (j *jsonReqBody) GetBody() (io.ReadCloser, error) {
2726
return &jsonReqBody{v: j.v}, nil
2827
}
2928

3029
func (j *jsonReqBody) Read(p []byte) (n int, err error) {
31-
if j.closed.Load() {
30+
if j.closed {
3231
return 0, io.ErrClosedPipe
3332
}
3433
if j.pr == nil {
@@ -65,10 +64,10 @@ func (j *jsonReqBody) Read(p []byte) (n int, err error) {
6564
}
6665

6766
func (j *jsonReqBody) Close() error {
68-
if j.closed.Load() {
67+
if j.closed {
6968
return io.ErrClosedPipe
7069
}
71-
j.closed.Store(true)
70+
j.closed = true
7271
return j.pr.Close()
7372
}
7473

0 commit comments

Comments
 (0)