History

restore original representation of `Tag` at the cost of some duplication

That way both representations are optimal in memory for their intended usecase. - `TagRef` is decodable from a buffer refers to it with all of its fields. That way round-trips are cheapest. - `Tag` does not allocate for hashes as there is a more compact representation: `git_hash::ObjectId`.

Sebastian Thiel committed 3 years ago

Commit dd0a23d1 parent 7242d1f6 files · +49 −59Browse files

Showing the changes to git-object/src/commit (1 of 6 files). Show all

Unified · Split

git-object/src/commit/write.rs+8−8
@@ -23,6 +23,10 @@ impl crate::WriteTo for Commit { · 22 unmodified lines
23 out.write_all(&self.message)23 out.write_all(&self.message)
24 }24 }
25 25
26 fn kind(&self) -> Kind {
27 Kind::Commit
28 }
29
26 fn size(&self) -> usize {30 fn size(&self) -> usize {
27 let hash_in_hex = self.tree.kind().len_in_hex();31 let hash_in_hex = self.tree.kind().len_in_hex();
28 b"tree".len() + 1 /*space*/ + hash_in_hex + 1 /* nl */32 b"tree".len() + 1 /*space*/ + hash_in_hex + 1 /* nl */
@@ -45,10 +49,6 @@ impl crate::WriteTo for Commit { · 16 unmodified lines
45 + 1 /* nl */49 + 1 /* nl */
46 + self.message.len()50 + self.message.len()
47 }51 }
48
49 fn kind(&self) -> Kind {
50 Kind::Commit
51 }
52}52}
53 53
54impl<'a> crate::WriteTo for CommitRef<'a> {54impl<'a> crate::WriteTo for CommitRef<'a> {
@@ -70,6 +70,10 @@ impl<'a> crate::WriteTo for CommitRef<'a> { · 15 unmodified lines
70 out.write_all(self.message)70 out.write_all(self.message)
71 }71 }
72 72
73 fn kind(&self) -> Kind {
74 Kind::Commit
75 }
76
73 fn size(&self) -> usize {77 fn size(&self) -> usize {
74 let hash_in_hex = self.tree().kind().len_in_hex();78 let hash_in_hex = self.tree().kind().len_in_hex();
75 b"tree".len() + 1 /* space */ + hash_in_hex + 1 /* nl */79 b"tree".len() + 1 /* space */ + hash_in_hex + 1 /* nl */
@@ -92,8 +96,4 @@ impl<'a> crate::WriteTo for CommitRef<'a> { · 16 unmodified lines
92 + 1 /* nl */96 + 1 /* nl */
93 + self.message.len()97 + self.message.len()
94 }98 }
95
96 fn kind(&self) -> Kind {
97 Kind::Commit
98 }
99}99}