@@ -327,19 +327,15 @@ def __init__(self, stream_list):
327327
328328 def _set_cache_ (self , attr ):
329329 """If we are here, we apply the actual deltas"""
330- # fill in delta info structures, providing the source and target buffer
331- # sizes.
332- buffer_offset_list = list ()
333- final_target_size = None
330+
331+ # prefetch information
332+ buffer_info_list = list ()
334333 max_target_size = 0
335334 for dstream in self ._dstreams :
336335 buf = dstream .read (512 ) # read the header information + X
337336 offset , src_size = msb_size (buf )
338337 offset , target_size = msb_size (buf , offset )
339- if final_target_size is None :
340- final_target_size = target_size
341- # END set final target size
342- buffer_offset_list .append ((buffer (buf , offset ), offset ))
338+ buffer_info_list .append ((buffer (buf , offset ), offset , src_size , target_size ))
343339 max_target_size = max (max_target_size , target_size )
344340 # END for each delta stream
345341
@@ -358,7 +354,7 @@ def _set_cache_(self, attr):
358354 # Allocate private memory map big enough to hold the first base buffer
359355 # We need random access to it
360356 bbuf = allocate_memory (base_size )
361- stream_copy (self ._bstream .read , bbuf .write , base_size , 256 * mmap .PAGESIZE )
357+ stream_copy (self ._bstream .read , bbuf .write , base_size , 256 * mmap .PAGESIZE )
362358
363359 # allocate memory map large enough for the largest (intermediate) target
364360 # We will use it as scratch space for all delta ops. If the final
@@ -370,7 +366,8 @@ def _set_cache_(self, attr):
370366 # work on the op-codes to reconstruct everything.
371367 # For the actual copying, we use a seek and write pattern of buffer
372368 # slices.
373- for (dbuf , offset ), dstream in reversed (zip (buffer_offset_list , self ._dstreams )):
369+ final_target_size = None
370+ for (dbuf , offset , src_size , target_size ), dstream in reversed (zip (buffer_info_list , self ._dstreams )):
374371 # allocate a buffer to hold all delta data - fill in the data for
375372 # fast access. We do this as we know that reading individual bytes
376373 # from our stream would be slower than necessary ( although possible )
@@ -381,15 +378,16 @@ def _set_cache_(self, attr):
381378 # read the rest from the stream. The size we give is larger than necessary
382379 stream_copy (dstream .read , ddata .write , dstream .size , 256 * mmap .PAGESIZE )
383380
384- ################################################################
385- apply_delta_data (bbuf , len ( bbuf ) , ddata , len (ddata ), tbuf )
386- ################################################################
381+ #######################################################################
382+ apply_delta_data (bbuf , src_size , ddata , len (ddata ), tbuf , target_size )
383+ #######################################################################
387384
388385 # finally, swap out source and target buffers. The target is now the
389386 # base for the next delta to apply
390387 bbuf , tbuf = tbuf , bbuf
391388 bbuf .seek (0 )
392389 tbuf .seek (0 )
390+ final_target_size = target_size
393391 # END for each delta to apply
394392
395393 # its already seeked to 0, constrain it to the actual size
0 commit comments