File tree 1 file changed +16
-3
lines changed
1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -442,9 +442,8 @@ impl TupleData {
442
442
TUPLE_DATA_TOAST_TAG => TupleData :: UnchangedToast ,
443
443
TUPLE_DATA_TEXT_TAG => {
444
444
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)
448
447
}
449
448
TUPLE_DATA_BINARY_TAG => {
450
449
let len = buf. read_i32 :: < BigEndian > ( ) ?;
@@ -778,6 +777,20 @@ impl Buffer {
778
777
self . idx = self . bytes . len ( ) ;
779
778
buf
780
779
}
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
+ }
781
794
}
782
795
783
796
impl Read for Buffer {
You can’t perform that action at this time.
0 commit comments