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
2323 out.write_all(&self.message)
2424 }
2525
26+ fn kind(&self) -> Kind {
27+ Kind::Commit
28+ }
29+
2630 fn size(&self) -> usize {
2731 let hash_in_hex = self.tree.kind().len_in_hex();
2832 b"tree".len() + 1 /*space*/ + hash_in_hex + 1 /* nl */
@@ -45,10 +49,6 @@ impl crate::WriteTo for Commit { · 16 unmodified lines
4549 + 1 /* nl */
4650 + self.message.len()
4751 }
48−
49− fn kind(&self) -> Kind {
50− Kind::Commit
51− }
5252 }
5353
5454 impl<'a> crate::WriteTo for CommitRef<'a> {
@@ -70,6 +70,10 @@ impl<'a> crate::WriteTo for CommitRef<'a> { · 15 unmodified lines
7070 out.write_all(self.message)
7171 }
7272
73+ fn kind(&self) -> Kind {
74+ Kind::Commit
75+ }
76+
7377 fn size(&self) -> usize {
7478 let hash_in_hex = self.tree().kind().len_in_hex();
7579 b"tree".len() + 1 /* space */ + hash_in_hex + 1 /* nl */
@@ -92,8 +96,4 @@ impl<'a> crate::WriteTo for CommitRef<'a> { · 16 unmodified lines
9296 + 1 /* nl */
9397 + self.message.len()
9498 }
95−
96− fn kind(&self) -> Kind {
97− Kind::Commit
98− }
9999 }