Skip to content

Commit ec349b0

Browse files
committed
refactor Stream to remove unnecessary bufio.Reader and use conn directly
1 parent 76171f0 commit ec349b0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

mod/nodes/src/frames/stream.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
package frames
33

44
import (
5-
"bufio"
65
"fmt"
76
"io"
87
"sync"
@@ -15,22 +14,17 @@ import (
1514
const inChanSize = 32
1615

1716
type Stream struct {
18-
conn io.ReadWriteCloser
19-
peeker *bufio.Reader
20-
17+
conn io.ReadWriteCloser
2118
err sig.Value[error]
2219
done chan struct{}
2320
read chan Frame
2421
mu sync.Mutex
2522
}
2623

2724
func NewStream(conn io.ReadWriteCloser) *Stream {
28-
peeker := bufio.NewReader(conn)
29-
3025
link := &Stream{
31-
peeker: peeker,
3226
conn: streams.ReadWriteCloseSplit{
33-
Reader: peeker,
27+
Reader: conn,
3428
Writer: conn,
3529
Closer: conn,
3630
},
@@ -87,7 +81,7 @@ func (s *Stream) reader() {
8781
}()
8882

8983
for {
90-
obj, _, derr := FrameBlueprints.Read(s.peeker)
84+
obj, _, derr := FrameBlueprints.Read(s.conn)
9185
if derr != nil {
9286
err = derr
9387
return
@@ -104,7 +98,13 @@ func (s *Stream) reader() {
10498
}
10599

106100
var FrameBlueprints = astral.NewBlueprints(nil).Indexed([]string{
107-
"nodes.frames.ping", "nodes.frames.query", "nodes.frames.response", "nodes.frames.read", "nodes.frames.data", "nodes.frames.migrate", "nodes.frames.reset",
101+
"nodes.frames.ping",
102+
"nodes.frames.query",
103+
"nodes.frames.response",
104+
"nodes.frames.read",
105+
"nodes.frames.data",
106+
"nodes.frames.migrate",
107+
"nodes.frames.reset",
108108
})
109109

110110
func init() {

0 commit comments

Comments
 (0)