branch: reset instead of release a strbuf
Our documentation advises to not re-use a strbuf, after strbuf_release has been called on it. Use the proper reset instead. Currently 'strbuf_release' releases and re-initializes the strbuf, so it is safe, but slow. 'strbuf_reset' only resets the internal length variable, such that this could also be accounted for as a micro-optimization. Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Oct 3, 2017 at 15:17 UTC
a9155c50bd52b7e27224e9588780ce5f972fa98d
1 file changed
+3
-2
builtin/branch.c
+3
-2
@@ -216,7 +216,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
216
if (!head_rev)
217
die(_("Couldn't look up commit object for HEAD"));
218
}
219
- for (i = 0; i < argc; i++, strbuf_release(&bname)) {
219
+ for (i = 0; i < argc; i++, strbuf_reset(&bname)) {
220
char *target = NULL;
221
int flags = 0;
222
@@ -281,8 +281,9 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
281
}
282
283
free(name);
284
+ strbuf_release(&bname);
285
285
- return(ret);
286
+ return ret;
287
}
288
289
static int calc_maxwidth(struct ref_array *refs, int remote_bonus)