@@ -534,13 +534,12 @@ uint DIV_count_slice_bytes(const DeltaInfoVector* src, uint ofs, uint size)
534534 }
535535
536536 const DeltaInfo const * vecend = DIV_end (src );
537+ const uchar * nstream ;
537538 for ( ;cdi < vecend ; ++ cdi ){
538- next_delta_info (src -> dstream + cdi -> dso , & dc );
539+ nstream = next_delta_info (src -> dstream + cdi -> dso , & dc );
539540
540541 if (dc .ts < size ) {
541- // TODO: could just count size of the delta chunk in the stream instead
542- // of reencoding
543- num_bytes += DC_count_encode_bytes (& dc );
542+ num_bytes += nstream - (src -> dstream + cdi -> dso );
544543 size -= dc .ts ;
545544 } else {
546545 dc .ts = size ;
@@ -589,16 +588,15 @@ uint DIV_copy_slice_to(const DeltaInfoVector* src, uchar** dest, ull tofs, uint
589588 }
590589 }
591590
592- const DeltaInfo * vecend = DIV_end (src );
593- for ( ;cdi < vecend ; ++ cdi )
591+ const uchar * dstream = src -> dstream + cdi -> dso ;
592+ const uchar * nstream = dstream ;
593+ for ( ; nstream ; dstream = nstream )
594594 {
595595 num_chunks += 1 ;
596- next_delta_info (src -> dstream + cdi -> dso , & dc );
596+ nstream = next_delta_info (dstream , & dc );
597597 if (dc .ts < size ) {
598- // Full copy would be possible, but the final length of the dstream
599- // needs to be used as well to know how many bytes to copy
600- // TODO: make a DIV_ function for this
601- DC_encode_to (& dc , dest , 0 , dc .ts );
598+ memcpy (* dest , dstream , nstream - dstream );
599+ * dest += nstream - dstream ;
602600 size -= dc .ts ;
603601 } else {
604602 DC_encode_to (& dc , dest , 0 , size );
0 commit comments