Commit 7b35eaf
sequencer: simplify memory allocation of get_message
For a commit with sha1 "1234abcd" and subject "foo", this
function produces a struct with three strings:
1. "foo"
2. "1234abcd... foo"
3. "parent of 1234abcd... foo"
It takes advantage of the fact that these strings are
subsets of each other, and allocates only _one_ string, with
pointers into the various parts. Unfortunately, this makes
the string allocation complicated and hard to follow.
Since we keep only one of these in memory at a time, we can
afford to simply allocate three strings. This lets us build
on tools like xstrfmt and avoid manual computation.
While we're here, we can also drop the ad-hoc
reimplementation of get_git_commit_encoding(), and simply
call that function.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 62f1751 commit 7b35eaf
1 file changed
+10
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
| 127 | + | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 135 | + | |
140 | 136 | | |
141 | | - | |
| 137 | + | |
142 | 138 | | |
143 | | - | |
144 | 139 | | |
145 | 140 | | |
146 | 141 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
157 | 146 | | |
158 | 147 | | |
159 | 148 | | |
160 | 149 | | |
161 | 150 | | |
162 | 151 | | |
| 152 | + | |
| 153 | + | |
163 | 154 | | |
164 | 155 | | |
165 | 156 | | |
| |||
0 commit comments