History

refactor

Sebastian Thiel committed 6 years ago

Commit 62a01fe1 parent d907ce83 files · +6 −29Browse files

Unified · Split

3 files
  1. git-odb/src/pack/index/write/error.rs +0 −9
  2. git-odb/src/pack/index/write/mod.rs +1 −15
  3. git-odb/tests/pack/tree.rs +5 −5
git-odb/src/pack/index/write/error.rs+0−9
@@ -24,21 +24,12 @@ quick_error! { · 23 unmodified lines
2424 IteratorInvariantTrailer {
2525 display("The iterator failed to set a trailing hash over all prior pack entries in the last provided entry")
2626 }
27− IteratorInvariantNonEmpty {
28− display("Is there ever a need to create empty indices? If so, please post a PR.")
29− }
3027 IteratorInvariantBasesPresent {
3128 display("Did not encounter a single base")
3229 }
33− IteratorInvariantBasesBeforeDeltasNeedThem(delta_pack_offset: u64, base_pack_offset: u64) {
34− display("The delta at pack offset {} could not find its base at {} - it should have been seen already", delta_pack_offset, base_pack_offset)
35− }
3630 IteratorInvariantTooManyObjects(num_objects: usize) {
3731 display("Only u32::MAX objects can be stored in a pack, found {}", num_objects)
3832 }
39− IteratorInvariantIncreasingPackOffset(last_pack_offset: u64, pack_offset: u64) {
40− display("Pack offsets must only increment. The previous pack offset was {}, the current one is {}", last_pack_offset, pack_offset)
41− }
4233 IteratorInvariantBaseOffset(pack_offset: u64, distance: u64) {
4334 display("{} is not a valid offset for pack offset {}", distance, pack_offset)
4435 }
git-odb/src/pack/index/write/mod.rs+1−15
@@ -37,14 +37,9 @@ impl pack::index::File { · 36 unmodified lines
3737 let mut bytes_to_process = 0u64;
3838 // This array starts out sorted by pack-offset
3939 let mut index_entries = Vec::with_capacity(entries.size_hint().0);
40− if index_entries.capacity() == 0 {
41− return Err(Error::IteratorInvariantNonEmpty);
42− }
43−
4440 let mut last_seen_trailer = None;
4541 let mut last_base_index = None;
4642 let mut first_delta_index = None;
47− let mut last_pack_offset = 0;
4843 let mut cache_by_offset = BTreeMap::<_, CacheEntry>::new();
4944 let mut tree = Tree::new(entries.size_hint().0)?;
5045 let mut header_buf = [0u8; 16];
@@ -66,13 +61,6 @@ impl pack::index::File { · 15 unmodified lines
6661 } = entry?;
6762
6863 let compressed_len = compressed.len();
69− if pack_offset <= last_pack_offset {
70− return Err(Error::IteratorInvariantIncreasingPackOffset(
71− last_pack_offset,
72− pack_offset,
73− ));
74− }
75− last_pack_offset = pack_offset;
7664 bytes_to_process += decompressed.len() as u64;
7765 let entry_len = header_size as usize + compressed_len;
7866 let crc32 = {
@@ -117,9 +105,7 @@ impl pack::index::File { · 38 unmodified lines
117105 )?;
118106 cache_by_offset
119107 .get_mut(&base_pack_offset)
120− .ok_or_else(|| {
121− Error::IteratorInvariantBasesBeforeDeltasNeedThem(pack_offset, base_pack_offset)
122− })?
108+ .expect("this to work nice check is done in tree delete me")
123109 .increment_child_count();
124110
125111 if first_delta_index.is_none() {
git-odb/tests/pack/tree.rs+5−5
@@ -1,14 +1,14 @@
11 #[test]
22 fn using_option_as_data_does_not_increase_size_in_memory() {
33 enum Cache {
4− Unset,
5− Decompressed(Vec<u8>),
4+ _Unset,
5+ _Decompressed(Vec<u8>),
66 /// compressed bytes + decompressed size
7− Compressed(Vec<u8>, usize),
7+ _Compressed(Vec<u8>, usize),
88 }
99 enum ObjectKind {
10− Base(git_object::Kind),
11− OfsDelta(u64),
10+ _Base(git_object::Kind),
11+ _OfsDelta(u64),
1212 }
1313 struct Entry {
1414 pub _pack_offset: u64,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t