{"thread":{"id":"53965","subject":"[RESEND PATCH] bisect: use oid_to_hex_r() instead of memcpy()+oid_to_hex()","startedAt":"2020-08-02T14:37:16Z","lastAt":"2020-08-02T20:03:15Z","messageCount":2,"participants":["René Scharfe","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"402648","messageId":"632682d5-e343-c069-f4b4-0451072d54d2@web.de","threadId":"53965","inReplyTo":null,"subject":"[RESEND PATCH] bisect: use oid_to_hex_r() instead of memcpy()+oid_to_hex()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2020-08-02T14:36:50Z","receivedAt":"2020-08-02T14:37:16Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Write the hexadecimal object ID directly into the destination buffer\nusing oid_to_hex_r() instead of writing it into a static buffer first\nusing oid_to_hex() and then copying it from there using memcpy().\nThis is shorter, simpler and a bit more efficient.\n\nReviewed-by: brian m. carlson <sandals@crustytoothpaste.net>\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\nOriginal submission (forgot to copy Junio):\nhttps://public-inbox.org/git/c2f9ec40-71f5-122c-add8-08d6a4bfa859@web.de/\n\n bisect.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex d5e830410f..be3ff1e962 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -709,7 +709,7 @@ static enum bisect_error bisect_checkout(const struct object_id *bisect_rev, int\n \tchar bisect_rev_hex[GIT_MAX_HEXSZ + 1];\n \tenum bisect_error res = BISECT_OK;\n\n-\tmemcpy(bisect_rev_hex, oid_to_hex(bisect_rev), the_hash_algo->hexsz + 1);\n+\toid_to_hex_r(bisect_rev_hex, bisect_rev);\n \tupdate_ref(NULL, \"BISECT_EXPECTED_REV\", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR);\n\n \targv_checkout[2] = bisect_rev_hex;\n--\n2.27.0\n"},{"id":"402670","messageId":"xmqqzh7crf29.fsf@gitster.c.googlers.com","threadId":"53965","inReplyTo":"632682d5-e343-c069-f4b4-0451072d54d2@web.de","subject":"Re: [RESEND PATCH] bisect: use oid_to_hex_r() instead of memcpy()+oid_to_hex()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-08-02T20:03:10Z","receivedAt":"2020-08-02T20:03:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <l.s.r@web.de> writes:\n\n> Write the hexadecimal object ID directly into the destination buffer\n> using oid_to_hex_r() instead of writing it into a static buffer first\n> using oid_to_hex() and then copying it from there using memcpy().\n> This is shorter, simpler and a bit more efficient.\n>\n> Reviewed-by: brian m. carlson <sandals@crustytoothpaste.net>\n> Signed-off-by: René Scharfe <l.s.r@web.de>\n> ---\n\nThanks.\n"}]}