mirror of
https://github.com/martinvonz/jj.git
synced 2024-11-13 06:06:56 +03:00
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.
This commit is contained in:
parent
038867fd3f
commit
e1c0d4fd5f
@ -305,14 +305,11 @@ impl CommitGraphEntry<'_> {
|
||||
// to better cache locality when walking it; ability to quickly find all
|
||||
// commits associated with a change id.
|
||||
fn change_id(&self) -> ChangeId {
|
||||
ChangeId::new(self.data[20..20 + self.change_id_length].to_vec())
|
||||
ChangeId::new(self.data[20..][..self.change_id_length].to_vec())
|
||||
}
|
||||
|
||||
fn commit_id(&self) -> CommitId {
|
||||
CommitId::from_bytes(
|
||||
&self.data
|
||||
[20 + self.change_id_length..20 + self.change_id_length + self.commit_id_length],
|
||||
)
|
||||
CommitId::from_bytes(&self.data[20 + self.change_id_length..][..self.commit_id_length])
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,7 +334,7 @@ impl CommitLookupEntry<'_> {
|
||||
|
||||
fn pos(&self) -> IndexPosition {
|
||||
IndexPosition(
|
||||
(&self.data[self.commit_id_length..self.commit_id_length + 4])
|
||||
(&self.data[self.commit_id_length..][..4])
|
||||
.read_u32::<LittleEndian>()
|
||||
.unwrap(),
|
||||
)
|
||||
@ -560,7 +557,7 @@ impl MutableIndexImpl {
|
||||
buf.write_u32::<LittleEndian>(pos.0).unwrap();
|
||||
}
|
||||
|
||||
(&mut buf[parent_overflow_offset..parent_overflow_offset + 4])
|
||||
(&mut buf[parent_overflow_offset..][..4])
|
||||
.write_u32::<LittleEndian>(parent_overflow.len() as u32)
|
||||
.unwrap();
|
||||
for parent_pos in parent_overflow {
|
||||
@ -1899,7 +1896,7 @@ impl ReadonlyIndexImpl {
|
||||
fn graph_entry(&self, local_pos: u32) -> CommitGraphEntry {
|
||||
let offset = (local_pos as usize) * self.commit_graph_entry_size;
|
||||
CommitGraphEntry {
|
||||
data: &self.graph[offset..offset + self.commit_graph_entry_size],
|
||||
data: &self.graph[offset..][..self.commit_graph_entry_size],
|
||||
commit_id_length: self.commit_id_length,
|
||||
change_id_length: self.change_id_length,
|
||||
}
|
||||
@ -1908,7 +1905,7 @@ impl ReadonlyIndexImpl {
|
||||
fn lookup_entry(&self, lookup_pos: u32) -> CommitLookupEntry {
|
||||
let offset = (lookup_pos as usize) * self.commit_lookup_entry_size;
|
||||
CommitLookupEntry {
|
||||
data: &self.lookup[offset..offset + self.commit_lookup_entry_size],
|
||||
data: &self.lookup[offset..][..self.commit_lookup_entry_size],
|
||||
commit_id_length: self.commit_id_length,
|
||||
}
|
||||
}
|
||||
@ -1916,7 +1913,7 @@ impl ReadonlyIndexImpl {
|
||||
fn overflow_parent(&self, overflow_pos: u32) -> IndexPosition {
|
||||
let offset = (overflow_pos as usize) * 4;
|
||||
IndexPosition(
|
||||
(&self.overflow_parent[offset..offset + 4])
|
||||
(&self.overflow_parent[offset..][..4])
|
||||
.read_u32::<LittleEndian>()
|
||||
.unwrap(),
|
||||
)
|
||||
|
@ -175,7 +175,7 @@ impl<'table> ReadonlyTableIndexEntry<'table> {
|
||||
fn new(table: &'table ReadonlyTable, pos: usize) -> Self {
|
||||
let entry_size = ReadonlyTableIndexEntry::size(table.key_size);
|
||||
let offset = entry_size * pos;
|
||||
let data = &table.index[offset..offset + entry_size];
|
||||
let data = &table.index[offset..][..entry_size];
|
||||
ReadonlyTableIndexEntry { data }
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ fn test_same_type(use_git: bool) {
|
||||
let write_tree = |index: usize| -> Tree {
|
||||
let mut tree_builder = store.tree_builder(store.empty_tree_id().clone());
|
||||
for path in &files {
|
||||
let contents = &path[index..index + 1];
|
||||
let contents = &path[index..][..1];
|
||||
if contents != "_" {
|
||||
testutils::write_normal_file(
|
||||
&mut tree_builder,
|
||||
@ -216,7 +216,7 @@ fn test_executable(use_git: bool) {
|
||||
fn contents_in_tree<'a>(files: &[&'a str], index: usize) -> Vec<(&'a str, bool)> {
|
||||
files
|
||||
.iter()
|
||||
.map(|f| (*f, &f[index..index + 1] == "x"))
|
||||
.map(|f| (*f, &f[index..][..1] == "x"))
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user