Skip to content

Commit

Permalink
Allocate fewer bytes per RPC request
Browse files Browse the repository at this point in the history
  • Loading branch information
joshklop authored and omerfirmak committed Sep 22, 2023
1 parent 3f6b7d3 commit e847234
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion jsonrpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const (
var (
ErrInvalidID = errors.New("id should be a string or an integer")

bufferSize = 128
contextInterface = reflect.TypeOf((*context.Context)(nil)).Elem()
)

Expand Down Expand Up @@ -198,7 +199,7 @@ func (s *Server) Handle(ctx context.Context, data []byte) ([]byte, error) {
// It returns the response in a byte array, only returns an
// error if it can not create the response byte array
func (s *Server) HandleReader(ctx context.Context, reader io.Reader) ([]byte, error) {
bufferedReader := bufio.NewReader(reader)
bufferedReader := bufio.NewReaderSize(reader, bufferSize)
requestIsBatch := isBatch(bufferedReader)
res := &response{
Version: "2.0",
Expand Down

0 comments on commit e847234

Please sign in to comment.