##// END OF EJS Templates
hg-core: renaming of `Chunk` offset methods (D8958#inline-15002 followup)...
Antoine cezar -
r46174:b68b1910 default
parent child Browse files
Show More
@@ -22,7 +22,7 b" impl Chunk<'_> {"
22 22 ///
23 23 /// The offset, taking into account the growth/shrinkage of data
24 24 /// induced by previously applied chunks.
25 fn start_offseted_by(&self, offset: i32) -> u32 {
25 fn start_offset_by(&self, offset: i32) -> u32 {
26 26 let start = self.start as i32 + offset;
27 27 assert!(start >= 0, "negative chunk start should never happen");
28 28 start as u32
@@ -32,8 +32,8 b" impl Chunk<'_> {"
32 32 ///
33 33 /// The offset, taking into account the growth/shrinkage of data
34 34 /// induced by previously applied chunks.
35 fn end_offseted_by(&self, offset: i32) -> u32 {
36 self.start_offseted_by(offset) + self.data.len() as u32
35 fn end_offset_by(&self, offset: i32) -> u32 {
36 self.start_offset_by(offset) + self.data.len() as u32
37 37 }
38 38
39 39 /// Length of the replaced chunk.
@@ -122,7 +122,7 b" impl<'a> PatchList<'a> {"
122 122 // Add chunks of `self` that start before this chunk of `other`
123 123 // without overlap.
124 124 while pos < self.chunks.len()
125 && self.chunks[pos].end_offseted_by(offset) <= *start
125 && self.chunks[pos].end_offset_by(offset) <= *start
126 126 {
127 127 let first = self.chunks[pos].clone();
128 128 offset += first.len_diff();
@@ -135,12 +135,12 b" impl<'a> PatchList<'a> {"
135 135 // The left-most part of data is added as an insertion chunk.
136 136 // The right-most part data is kept in the chunk.
137 137 if pos < self.chunks.len()
138 && self.chunks[pos].start_offseted_by(offset) < *start
138 && self.chunks[pos].start_offset_by(offset) < *start
139 139 {
140 140 let first = &mut self.chunks[pos];
141 141
142 142 let (data_left, data_right) = first.data.split_at(
143 (*start - first.start_offseted_by(offset)) as usize,
143 (*start - first.start_offset_by(offset)) as usize,
144 144 );
145 145 let left = Chunk {
146 146 start: first.start,
@@ -170,7 +170,7 b" impl<'a> PatchList<'a> {"
170 170 // Discard the chunks of `self` that are totally overridden
171 171 // by the current chunk of `other`
172 172 while pos < self.chunks.len()
173 && self.chunks[pos].end_offseted_by(next_offset) <= *end
173 && self.chunks[pos].end_offset_by(next_offset) <= *end
174 174 {
175 175 let first = &self.chunks[pos];
176 176 next_offset += first.len_diff();
@@ -180,12 +180,12 b" impl<'a> PatchList<'a> {"
180 180 // Truncate the left-most part of chunk of `self` that overlaps
181 181 // the current chunk of `other`.
182 182 if pos < self.chunks.len()
183 && self.chunks[pos].start_offseted_by(next_offset) < *end
183 && self.chunks[pos].start_offset_by(next_offset) < *end
184 184 {
185 185 let first = &mut self.chunks[pos];
186 186
187 187 let how_much_to_discard =
188 *end - first.start_offseted_by(next_offset);
188 *end - first.start_offset_by(next_offset);
189 189
190 190 first.data = &first.data[(how_much_to_discard as usize)..];
191 191
General Comments 0
You need to be logged in to leave comments. Login now