Skip to content

Commit

Permalink
Merge pull request #103 from spatial-go/102-readbytes-buffer-is-1-byt…
Browse files Browse the repository at this point in the history
…e-ultra-slow

Modify the ReadBytes method buffer size
  • Loading branch information
coolwxb authored Oct 16, 2023
2 parents 85af135 + 128b227 commit e47d35d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions geoencoding/geojson/base_encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ func (e *BaseEncoder) Read(r io.Reader) (space.Geometry, error) {
// ReadBytes Returns geometry from reader.
func (e *BaseEncoder) ReadBytes(r io.Reader) ([]byte, error) {
buf := []byte{}
b := make([]byte, 1)
b := make([]byte, 4096)
for {
if _, err := r.Read(b); err == io.EOF {
//buf = append(buf, b[0:n]...)
break
} else if err != nil {
return nil, err
} else {
buf = append(buf, b...)
}
n, err := r.Read(b)
if err != nil && err != io.EOF {
return nil,err
}
buf = append(buf, b[:n]...)
if err == io.EOF {
break
}
}
return buf, nil
}
Expand Down

0 comments on commit e47d35d

Please sign in to comment.