Unified · Split
| @@ -24,21 +24,12 @@ quick_error! { · 23 unmodified lines | ||
| 24 | 24 | IteratorInvariantTrailer { |
| 25 | 25 | display("The iterator failed to set a trailing hash over all prior pack entries in the last provided entry") |
| 26 | 26 | } |
| 27 | − IteratorInvariantNonEmpty { | |
| 28 | − display("Is there ever a need to create empty indices? If so, please post a PR.") | |
| 29 | − } | |
| 30 | 27 | IteratorInvariantBasesPresent { |
| 31 | 28 | display("Did not encounter a single base") |
| 32 | 29 | } |
| 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 | − } | |
| 36 | 30 | IteratorInvariantTooManyObjects(num_objects: usize) { |
| 37 | 31 | display("Only u32::MAX objects can be stored in a pack, found {}", num_objects) |
| 38 | 32 | } |
| 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 | − } | |
| 42 | 33 | IteratorInvariantBaseOffset(pack_offset: u64, distance: u64) { |
| 43 | 34 | display("{} is not a valid offset for pack offset {}", distance, pack_offset) |
| 44 | 35 | } |
| @@ -37,14 +37,9 @@ impl pack::index::File { · 36 unmodified lines | ||
| 37 | 37 | let mut bytes_to_process = 0u64; |
| 38 | 38 | // This array starts out sorted by pack-offset |
| 39 | 39 | let mut index_entries = Vec::with_capacity(entries.size_hint().0); |
| 40 | − if index_entries.capacity() == 0 { | |
| 41 | − return Err(Error::IteratorInvariantNonEmpty); | |
| 42 | − } | |
| 43 | − | |
| 44 | 40 | let mut last_seen_trailer = None; |
| 45 | 41 | let mut last_base_index = None; |
| 46 | 42 | let mut first_delta_index = None; |
| 47 | − let mut last_pack_offset = 0; | |
| 48 | 43 | let mut cache_by_offset = BTreeMap::<_, CacheEntry>::new(); |
| 49 | 44 | let mut tree = Tree::new(entries.size_hint().0)?; |
| 50 | 45 | let mut header_buf = [0u8; 16]; |
| @@ -66,13 +61,6 @@ impl pack::index::File { · 15 unmodified lines | ||
| 66 | 61 | } = entry?; |
| 67 | 62 | |
| 68 | 63 | 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; | |
| 76 | 64 | bytes_to_process += decompressed.len() as u64; |
| 77 | 65 | let entry_len = header_size as usize + compressed_len; |
| 78 | 66 | let crc32 = { |
| @@ -117,9 +105,7 @@ impl pack::index::File { · 38 unmodified lines | ||
| 117 | 105 | )?; |
| 118 | 106 | cache_by_offset |
| 119 | 107 | .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") | |
| 123 | 109 | .increment_child_count(); |
| 124 | 110 | |
| 125 | 111 | if first_delta_index.is_none() { |
| @@ -1,14 +1,14 @@ | ||
| 1 | 1 | #[test] |
| 2 | 2 | fn using_option_as_data_does_not_increase_size_in_memory() { |
| 3 | 3 | enum Cache { |
| 4 | − Unset, | |
| 5 | − Decompressed(Vec<u8>), | |
| 4 | + _Unset, | |
| 5 | + _Decompressed(Vec<u8>), | |
| 6 | 6 | /// compressed bytes + decompressed size |
| 7 | − Compressed(Vec<u8>, usize), | |
| 7 | + _Compressed(Vec<u8>, usize), | |
| 8 | 8 | } |
| 9 | 9 | enum ObjectKind { |
| 10 | − Base(git_object::Kind), | |
| 11 | − OfsDelta(u64), | |
| 10 | + _Base(git_object::Kind), | |
| 11 | + _OfsDelta(u64), | |
| 12 | 12 | } |
| 13 | 13 | struct Entry { |
| 14 | 14 | pub _pack_offset: u64, |