forked from mirrors/jj
index, stacked_table: simply extend Vec<u8> to not use .write_all()
I'm going to remove use of .write_u32() there. It's not super important, but fewer .unwrap()s, the code looks slightly better.
This commit is contained in:
parent
fb06e89649
commit
392539fa29
2 changed files with 7 additions and 7 deletions
|
@ -174,7 +174,7 @@ impl MutableIndexSegment {
|
||||||
if let Some(parent_file) = &self.parent_file {
|
if let Some(parent_file) = &self.parent_file {
|
||||||
buf.write_u32::<LittleEndian>(parent_file.name().len() as u32)
|
buf.write_u32::<LittleEndian>(parent_file.name().len() as u32)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
buf.write_all(parent_file.name().as_bytes()).unwrap();
|
buf.extend_from_slice(parent_file.name().as_bytes());
|
||||||
} else {
|
} else {
|
||||||
buf.write_u32::<LittleEndian>(0).unwrap();
|
buf.write_u32::<LittleEndian>(0).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -212,14 +212,14 @@ impl MutableIndexSegment {
|
||||||
buf.write_u32::<LittleEndian>(parent_overflow_pos).unwrap();
|
buf.write_u32::<LittleEndian>(parent_overflow_pos).unwrap();
|
||||||
|
|
||||||
assert_eq!(entry.change_id.as_bytes().len(), self.change_id_length);
|
assert_eq!(entry.change_id.as_bytes().len(), self.change_id_length);
|
||||||
buf.write_all(entry.change_id.as_bytes()).unwrap();
|
buf.extend_from_slice(entry.change_id.as_bytes());
|
||||||
|
|
||||||
assert_eq!(entry.commit_id.as_bytes().len(), self.commit_id_length);
|
assert_eq!(entry.commit_id.as_bytes().len(), self.commit_id_length);
|
||||||
buf.write_all(entry.commit_id.as_bytes()).unwrap();
|
buf.extend_from_slice(entry.commit_id.as_bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (commit_id, pos) in &self.lookup {
|
for (commit_id, pos) in &self.lookup {
|
||||||
buf.write_all(commit_id.as_bytes()).unwrap();
|
buf.extend_from_slice(commit_id.as_bytes());
|
||||||
buf.write_u32::<LittleEndian>(pos.0).unwrap();
|
buf.write_u32::<LittleEndian>(pos.0).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ impl MutableTable {
|
||||||
if let Some(parent_file) = &self.parent_file {
|
if let Some(parent_file) = &self.parent_file {
|
||||||
buf.write_u32::<LittleEndian>(parent_file.name.len() as u32)
|
buf.write_u32::<LittleEndian>(parent_file.name.len() as u32)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
buf.write_all(parent_file.name.as_bytes()).unwrap();
|
buf.extend_from_slice(parent_file.name.as_bytes());
|
||||||
} else {
|
} else {
|
||||||
buf.write_u32::<LittleEndian>(0).unwrap();
|
buf.write_u32::<LittleEndian>(0).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -268,12 +268,12 @@ impl MutableTable {
|
||||||
|
|
||||||
let mut value_offset = 0;
|
let mut value_offset = 0;
|
||||||
for (key, value) in &self.entries {
|
for (key, value) in &self.entries {
|
||||||
buf.write_all(key).unwrap();
|
buf.extend_from_slice(key);
|
||||||
buf.write_u32::<LittleEndian>(value_offset).unwrap();
|
buf.write_u32::<LittleEndian>(value_offset).unwrap();
|
||||||
value_offset += value.len() as u32;
|
value_offset += value.len() as u32;
|
||||||
}
|
}
|
||||||
for value in self.entries.values() {
|
for value in self.entries.values() {
|
||||||
buf.write_all(value).unwrap();
|
buf.extend_from_slice(value);
|
||||||
}
|
}
|
||||||
buf
|
buf
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue