File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -442,9 +442,8 @@ impl TupleData {
442442 TUPLE_DATA_TOAST_TAG => TupleData :: UnchangedToast ,
443443 TUPLE_DATA_TEXT_TAG => {
444444 let len = buf. read_i32 :: < BigEndian > ( ) ?;
445- let mut data = vec ! [ 0 ; len as usize ] ;
446- buf. read_exact ( & mut data) ?;
447- TupleData :: Text ( data. into ( ) )
445+ let data = buf. read_buf ( len as usize ) ?;
446+ TupleData :: Text ( data)
448447 }
449448 TUPLE_DATA_BINARY_TAG => {
450449 let len = buf. read_i32 :: < BigEndian > ( ) ?;
@@ -778,6 +777,20 @@ impl Buffer {
778777 self . idx = self . bytes . len ( ) ;
779778 buf
780779 }
780+
781+ #[ inline]
782+ fn read_buf ( & mut self , len : usize ) -> io:: Result < Bytes > {
783+ if self . idx + len <= self . bytes . len ( ) {
784+ let buf = self . bytes . slice ( self . idx ..( self . idx + len) ) ;
785+ self . idx += len;
786+ Ok ( buf)
787+ } else {
788+ Err ( io:: Error :: new (
789+ io:: ErrorKind :: UnexpectedEof ,
790+ "unexpected EOF" ,
791+ ) )
792+ }
793+ }
781794}
782795
783796impl Read for Buffer {
You can’t perform that action at this time.
0 commit comments