History

refactor

Sebastian Thiel committed 6 years ago

Commit 400a2a91 parent a0741931 file · +7 −7Browse files

Unified · Split

git-odb/src/pack/data/decode.rs+7−7
@@ -347,13 +347,13 @@ impl File { · 346 unmodified lines
347347 result_size,
348348 ..
349349 },
350− ) in chain.iter().rev().enumerate()
350+ ) in chain.into_iter().rev().enumerate()
351351 {
352− let data = &mut instructions[data.clone()];
352+ let data = &mut instructions[data];
353353 if delta_idx + 1 == chain_len {
354− last_result_size = Some(*result_size);
354+ last_result_size = Some(result_size);
355355 }
356− apply_delta(&source_buf[..*base_size], &mut target_buf[..*result_size], data);
356+ apply_delta(&source_buf[..base_size], &mut target_buf[..result_size], data);
357357 // use the target as source for the next delta
358358 std::mem::swap(&mut source_buf, &mut target_buf);
359359 }
@@ -367,7 +367,7 @@ impl File { · 7 unmodified lines
367367 // object, which should also be placed in the second buffer right away. You don't have that
368368 // control/knowledge for out-of-pack bases, so this is a special case to deal with, too.
369369 // Maybe these invariants can be represented in the type system though.
370− if chain.len() % 2 == 1 {
370+ if chain_len % 2 == 1 {
371371 // this seems inverted, but remember: we swapped the buffers on the last iteration
372372 target_buf[..last_result_size].copy_from_slice(&source_buf[..last_result_size]);
373373 }
@@ -381,7 +381,7 @@ impl File { · 7 unmodified lines
381381 // technically depending on the cache, the chain size is not correct as it might
382382 // have been cut short by a cache hit. The caller must deactivate the cache to get
383383 // actual results
384− num_deltas: chain.len() as u32,
384+ num_deltas: chain_len as u32,
385385 decompressed_size: first_entry.decompressed_size as u64,
386386 compressed_size: consumed_input,
387387 object_size: last_result_size as u64,
@@ -389,7 +389,7 @@ impl File { · 1 unmodified line
389389 }
390390 }
391391
392−fn apply_delta(base: &[u8], mut target: &mut [u8], data: &[u8]) {
392+pub(crate) fn apply_delta(base: &[u8], mut target: &mut [u8], data: &[u8]) {
393393 let mut i = 0;
394394 while let Some(cmd) = data.get(i) {
395395 i += 1;