History

refactor

Sebastian Thiel committed 6 years ago

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

Showing the changes to git-odb/src (1 of 1 file). Show all

Unified · Split

git-odb/src/pack/data/decode.rs+7−7
@@ -347,13 +347,13 @@ impl File { · 346 unmodified lines
347 result_size,347 result_size,
348 ..348 ..
349 },349 },
350 ) in chain.iter().rev().enumerate()350 ) in chain.into_iter().rev().enumerate()
351 {351 {
352 let data = &mut instructions[data.clone()];352 let data = &mut instructions[data];
353 if delta_idx + 1 == chain_len {353 if delta_idx + 1 == chain_len {
354 last_result_size = Some(*result_size);354 last_result_size = Some(result_size);
355 }355 }
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);
357 // use the target as source for the next delta357 // use the target as source for the next delta
358 std::mem::swap(&mut source_buf, &mut target_buf);358 std::mem::swap(&mut source_buf, &mut target_buf);
359 }359 }
@@ -367,7 +367,7 @@ impl File { · 7 unmodified lines
367 // object, which should also be placed in the second buffer right away. You don't have that367 // object, which should also be placed in the second buffer right away. You don't have that
368 // control/knowledge for out-of-pack bases, so this is a special case to deal with, too.368 // control/knowledge for out-of-pack bases, so this is a special case to deal with, too.
369 // Maybe these invariants can be represented in the type system though.369 // Maybe these invariants can be represented in the type system though.
370 if chain.len() % 2 == 1 {370 if chain_len % 2 == 1 {
371 // this seems inverted, but remember: we swapped the buffers on the last iteration371 // this seems inverted, but remember: we swapped the buffers on the last iteration
372 target_buf[..last_result_size].copy_from_slice(&source_buf[..last_result_size]);372 target_buf[..last_result_size].copy_from_slice(&source_buf[..last_result_size]);
373 }373 }
@@ -381,7 +381,7 @@ impl File { · 7 unmodified lines
381 // technically depending on the cache, the chain size is not correct as it might381 // technically depending on the cache, the chain size is not correct as it might
382 // have been cut short by a cache hit. The caller must deactivate the cache to get382 // have been cut short by a cache hit. The caller must deactivate the cache to get
383 // actual results383 // actual results
384 num_deltas: chain.len() as u32,384 num_deltas: chain_len as u32,
385 decompressed_size: first_entry.decompressed_size as u64,385 decompressed_size: first_entry.decompressed_size as u64,
386 compressed_size: consumed_input,386 compressed_size: consumed_input,
387 object_size: last_result_size as u64,387 object_size: last_result_size as u64,
@@ -389,7 +389,7 @@ impl File { · 1 unmodified line
389 }389 }
390}390}
391 391
392fn apply_delta(base: &[u8], mut target: &mut [u8], data: &[u8]) {392pub(crate) fn apply_delta(base: &[u8], mut target: &mut [u8], data: &[u8]) {
393 let mut i = 0;393 let mut i = 0;
394 while let Some(cmd) = data.get(i) {394 while let Some(cmd) = data.get(i) {
395 i += 1;395 i += 1;