just playing with tangled
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cleanup: replace `x[n..n+l]` by `x[n..][..l]`

This avoids repeating the `n` in these expressions. Thanks to
@Dr-Emann for the suggestion.

authored by

Martin von Zweigbergk and committed by
Martin von Zweigbergk
e1c0d4fd 038867fd

+10 -13
+7 -10
lib/src/default_index_store.rs
··· 305 305 // to better cache locality when walking it; ability to quickly find all 306 306 // commits associated with a change id. 307 307 fn change_id(&self) -> ChangeId { 308 - ChangeId::new(self.data[20..20 + self.change_id_length].to_vec()) 308 + ChangeId::new(self.data[20..][..self.change_id_length].to_vec()) 309 309 } 310 310 311 311 fn commit_id(&self) -> CommitId { 312 - CommitId::from_bytes( 313 - &self.data 314 - [20 + self.change_id_length..20 + self.change_id_length + self.commit_id_length], 315 - ) 312 + CommitId::from_bytes(&self.data[20 + self.change_id_length..][..self.commit_id_length]) 316 313 } 317 314 } 318 315 ··· 337 334 338 335 fn pos(&self) -> IndexPosition { 339 336 IndexPosition( 340 - (&self.data[self.commit_id_length..self.commit_id_length + 4]) 337 + (&self.data[self.commit_id_length..][..4]) 341 338 .read_u32::<LittleEndian>() 342 339 .unwrap(), 343 340 ) ··· 560 557 buf.write_u32::<LittleEndian>(pos.0).unwrap(); 561 558 } 562 559 563 - (&mut buf[parent_overflow_offset..parent_overflow_offset + 4]) 560 + (&mut buf[parent_overflow_offset..][..4]) 564 561 .write_u32::<LittleEndian>(parent_overflow.len() as u32) 565 562 .unwrap(); 566 563 for parent_pos in parent_overflow { ··· 1899 1896 fn graph_entry(&self, local_pos: u32) -> CommitGraphEntry { 1900 1897 let offset = (local_pos as usize) * self.commit_graph_entry_size; 1901 1898 CommitGraphEntry { 1902 - data: &self.graph[offset..offset + self.commit_graph_entry_size], 1899 + data: &self.graph[offset..][..self.commit_graph_entry_size], 1903 1900 commit_id_length: self.commit_id_length, 1904 1901 change_id_length: self.change_id_length, 1905 1902 } ··· 1908 1905 fn lookup_entry(&self, lookup_pos: u32) -> CommitLookupEntry { 1909 1906 let offset = (lookup_pos as usize) * self.commit_lookup_entry_size; 1910 1907 CommitLookupEntry { 1911 - data: &self.lookup[offset..offset + self.commit_lookup_entry_size], 1908 + data: &self.lookup[offset..][..self.commit_lookup_entry_size], 1912 1909 commit_id_length: self.commit_id_length, 1913 1910 } 1914 1911 } ··· 1916 1913 fn overflow_parent(&self, overflow_pos: u32) -> IndexPosition { 1917 1914 let offset = (overflow_pos as usize) * 4; 1918 1915 IndexPosition( 1919 - (&self.overflow_parent[offset..offset + 4]) 1916 + (&self.overflow_parent[offset..][..4]) 1920 1917 .read_u32::<LittleEndian>() 1921 1918 .unwrap(), 1922 1919 )
+1 -1
lib/src/stacked_table.rs
··· 175 175 fn new(table: &'table ReadonlyTable, pos: usize) -> Self { 176 176 let entry_size = ReadonlyTableIndexEntry::size(table.key_size); 177 177 let offset = entry_size * pos; 178 - let data = &table.index[offset..offset + entry_size]; 178 + let data = &table.index[offset..][..entry_size]; 179 179 ReadonlyTableIndexEntry { data } 180 180 } 181 181
+2 -2
lib/tests/test_merge_trees.rs
··· 54 54 let write_tree = |index: usize| -> Tree { 55 55 let mut tree_builder = store.tree_builder(store.empty_tree_id().clone()); 56 56 for path in &files { 57 - let contents = &path[index..index + 1]; 57 + let contents = &path[index..][..1]; 58 58 if contents != "_" { 59 59 testutils::write_normal_file( 60 60 &mut tree_builder, ··· 216 216 fn contents_in_tree<'a>(files: &[&'a str], index: usize) -> Vec<(&'a str, bool)> { 217 217 files 218 218 .iter() 219 - .map(|f| (*f, &f[index..index + 1] == "x")) 219 + .map(|f| (*f, &f[index..][..1] == "x")) 220 220 .collect() 221 221 } 222 222