@matheusbsbs / matheus-bagliano / commits / 7d23ff818f
Fork 0

bisect: use oid_to_hex_r() instead of memcpy()+oid_to_hex()

Write the hexadecimal object ID directly into the destination buffer using oid_to_hex_r() instead of writing it into a static buffer first using oid_to_hex() and then copying it from there using memcpy(). This is shorter, simpler and a bit more efficient. Reviewed-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Aug 2, 2020 at 16:36 UTC 7d23ff818f156da48882bec9ac84fb4e33dd619a
1 file changed +1 -1
bisect.c
+1 -1
@@ -709,7 +709,7 @@ static enum bisect_error bisect_checkout(const struct object_id *bisect_rev, int
709 char bisect_rev_hex[GIT_MAX_HEXSZ + 1];
710 enum bisect_error res = BISECT_OK;
711
712 - memcpy(bisect_rev_hex, oid_to_hex(bisect_rev), the_hash_algo->hexsz + 1);
712 + oid_to_hex_r(bisect_rev_hex, bisect_rev);
713 update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR);
714
715 argv_checkout[2] = bisect_rev_hex;