{"thread":{"id":"53924","subject":"[PATCH] bisect: use oid_to_hex_r() instead of memcpy()+oid_to_hex()","startedAt":"2020-07-26T17:41:18Z","lastAt":"2020-07-26T19:02:23Z","messageCount":2,"participants":["René Scharfe","brian m. carlson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"402061","messageId":"c2f9ec40-71f5-122c-add8-08d6a4bfa859@web.de","threadId":"53924","inReplyTo":null,"subject":"[PATCH] bisect: use oid_to_hex_r() instead of memcpy()+oid_to_hex()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2020-07-26T17:41:12Z","receivedAt":"2020-07-26T17:41:18Z","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\nSigned-off-by: René Scharfe <l.s.r@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":"402063","messageId":"20200726190214.GB6540@camp.crustytoothpaste.net","threadId":"53924","inReplyTo":"c2f9ec40-71f5-122c-add8-08d6a4bfa859@web.de","subject":"Re: [PATCH] bisect: use oid_to_hex_r() instead of memcpy()+oid_to_hex()","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-07-26T19:02:14Z","receivedAt":"2020-07-26T19:02:23Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2020-07-26 at 17:41:12, René Scharfe wrote:\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> Signed-off-by: René Scharfe <l.s.r@web.de>\n> ---\n>  bisect.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/bisect.c b/bisect.c\n> index 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\nYeah, this seems better in pretty much every way, and as a nice perk we\nlose an explicit dependency on the_hash_algo.\n-- \nbrian m. carlson: Houston, Texas, US\n"}]}