Showing the changes to git-object/src/commit (1 of 7 files). Show all
Unified · Split
| @@ -23,24 +23,15 @@ impl crate::WriteTo for Commit { · 22 unmodified lines | ||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | fn size(&self) -> usize { |
| 26 | − let hashsize = self.tree.kind().len_in_hex(); | |
| 27 | − b"tree".len() | |
| 28 | − + 1 | |
| 29 | − + hashsize | |
| 30 | − + 1 | |
| 31 | − + self.parents.iter().count() * (b"parent".len() + 1 + hashsize + 1) | |
| 32 | − + b"author".len() | |
| 33 | − + 1 | |
| 34 | − + self.author.size() | |
| 35 | − + 1 | |
| 36 | − + b"committer".len() | |
| 37 | − + 1 | |
| 38 | − + self.committer.size() | |
| 39 | − + 1 | |
| 26 | + let hash_in_hex = self.tree.kind().len_in_hex(); | |
| 27 | + b"tree".len() + 1 /*space*/ + hash_in_hex + 1 /* nl */ | |
| 28 | + + self.parents.iter().count() * (b"parent".len() + 1 + hash_in_hex + 1) | |
| 29 | + + b"author".len() + 1 /* space */ + self.author.size() + 1 /* nl */ | |
| 30 | + + b"committer".len() + 1 /* space */ + self.committer.size() + 1 /* nl */ | |
| 40 | 31 | + self |
| 41 | 32 | .encoding |
| 42 | 33 | .as_ref() |
| 43 | − .map(|e| b"encoding".len() + 1 + e.len() + 1) | |
| 34 | + .map(|e| b"encoding".len() + 1 /* space */ + e.len() + 1 /* nl */) | |
| 44 | 35 | .unwrap_or(0) |
| 45 | 36 | + self |
| 46 | 37 | .extra_headers |
| @@ -50,7 +41,7 @@ impl crate::WriteTo for Commit { · 3 unmodified lines | ||
| 50 | 41 | name.len() + value.split_str("\n").map(|s| s.len() + 2).sum::<usize>() |
| 51 | 42 | }) |
| 52 | 43 | .sum::<usize>() |
| 53 | − + 1 | |
| 44 | + + 1 /* nl */ | |
| 54 | 45 | + self.message.len() |
| 55 | 46 | } |
| 56 | 47 | |
| @@ -79,24 +70,15 @@ impl<'a> crate::WriteTo for CommitRef<'a> { · 22 unmodified lines | ||
| 79 | 70 | } |
| 80 | 71 | |
| 81 | 72 | fn size(&self) -> usize { |
| 82 | − let hashsize = self.tree().kind().len_in_hex(); | |
| 83 | − b"tree".len() | |
| 84 | − + 1 | |
| 85 | − + hashsize | |
| 86 | − + 1 | |
| 87 | − + self.parents.iter().count() * (b"parent".len() + 1 + hashsize + 1) | |
| 88 | − + b"author".len() | |
| 89 | − + 1 | |
| 90 | − + self.author.size() | |
| 91 | − + 1 | |
| 92 | − + b"committer".len() | |
| 93 | − + 1 | |
| 94 | − + self.committer.size() | |
| 95 | − + 1 | |
| 73 | + let hash_in_hex = self.tree().kind().len_in_hex(); | |
| 74 | + b"tree".len() + 1 /* space */ + hash_in_hex + 1 /* nl */ | |
| 75 | + + self.parents.iter().count() * (b"parent".len() + 1 /* space */ + hash_in_hex + 1 /* nl */) | |
| 76 | + + b"author".len() + 1 /* space */ + self.author.size() + 1 /* nl */ | |
| 77 | + + b"committer".len() + 1 /* space */ + self.committer.size() + 1 /* nl */ | |
| 96 | 78 | + self |
| 97 | 79 | .encoding |
| 98 | 80 | .as_ref() |
| 99 | − .map(|e| b"encoding".len() + 1 + e.len() + 1) | |
| 81 | + .map(|e| b"encoding".len() + 1 /* space */ + e.len() + 1 /* nl */) | |
| 100 | 82 | .unwrap_or(0) |
| 101 | 83 | + self |
| 102 | 84 | .extra_headers |
| @@ -106,7 +88,7 @@ impl<'a> crate::WriteTo for CommitRef<'a> { · 3 unmodified lines | ||
| 106 | 88 | name.len() + value.split_str("\n").map(|s| s.len() + 2).sum::<usize>() |
| 107 | 89 | }) |
| 108 | 90 | .sum::<usize>() |
| 109 | − + 1 | |
| 91 | + + 1 /* nl */ | |
| 110 | 92 | + self.message.len() |
| 111 | 93 | } |
| 112 | 94 | |