File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -750,12 +750,13 @@ where
750750 // +8: some 'random' padding
751751 let buf_len = ( delay / Self :: C32 + 8 ) . next_power_of_two ( ) ;
752752 let buf_mask = buf_len - 1 ;
753- if buf. len ( ) != buf_len {
753+ if buf. capacity ( ) < buf_len {
754754 // This has better codegen than `vec.clear(); vec.resize()`, since the inner `do_reserve_and_handle` of resize is not inlined.
755- * buf. as_mut ( ) = vec ! [ S :: ZERO ; buf_len] ;
755+ * buf = vec ! [ S :: ZERO ; buf_len] ;
756756 } else {
757757 // NOTE: Buf needs to be filled with zeros to guarantee returning 0 values for out-of-bounds characters.
758- buf. fill ( S :: ZERO ) ;
758+ buf. clear ( ) ;
759+ buf. resize ( buf_len, S :: ZERO ) ;
759760 }
760761
761762 let mut write_idx = 0 ;
@@ -899,12 +900,13 @@ where
899900 // Even buf_len is nice to only have the write==buf_len check once.
900901 let buf_len = ( delay2 / Self :: C32 + 8 ) . next_power_of_two ( ) ;
901902 let buf_mask = buf_len - 1 ;
902- if buf. len ( ) != buf_len {
903+ if buf. capacity ( ) < buf_len {
903904 // This has better codegen than `vec.clear(); vec.resize()`, since the inner `do_reserve_and_handle` of resize is not inlined.
904905 * buf = vec ! [ S :: ZERO ; buf_len] ;
905906 } else {
906907 // NOTE: Buf needs to be filled with zeros to guarantee returning 0 values for out-of-bounds characters.
907- buf. fill ( S :: ZERO ) ;
908+ buf. clear ( ) ;
909+ buf. resize ( buf_len, S :: ZERO ) ;
908910 }
909911
910912 let mut write_idx = 0 ;
You can’t perform that action at this time.
0 commit comments