# [RESEND PATCH] bisect: use oid_to_hex_r() instead of memcpy()+oid_to_hex()

2 messages from 2020-08-02 to 2020-08-02. Participants: René Scharfe, Junio C Hamano.
Thread: https://gitlist.dev/t/53965

## René Scharfe, 2020-08-02 14:36

Subject: [RESEND PATCH] bisect: use oid_to_hex_r() instead of memcpy()+oid_to_hex()
Message-ID: <632682d5-e343-c069-f4b4-0451072d54d2@web.de>
URL: https://gitlist.dev/e/632682d5-e343-c069-f4b4-0451072d54d2%40web.de

```
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>
---
Original submission (forgot to copy Junio):
https://public-inbox.org/git/c2f9ec40-71f5-122c-add8-08d6a4bfa859@web.de/

 bisect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bisect.c b/bisect.c
index d5e830410f..be3ff1e962 100644
--- a/bisect.c
+++ b/bisect.c
@@ -709,7 +709,7 @@ static enum bisect_error bisect_checkout(const struct object_id *bisect_rev, int
 	char bisect_rev_hex[GIT_MAX_HEXSZ + 1];
 	enum bisect_error res = BISECT_OK;

-	memcpy(bisect_rev_hex, oid_to_hex(bisect_rev), the_hash_algo->hexsz + 1);
+	oid_to_hex_r(bisect_rev_hex, bisect_rev);
 	update_ref(NULL, "BISECT_EXPECTED_REV", bisect_rev, NULL, 0, UPDATE_REFS_DIE_ON_ERR);

 	argv_checkout[2] = bisect_rev_hex;
--
2.27.0

```

## Junio C Hamano, 2020-08-02 20:03

Subject: Re: [RESEND PATCH] bisect: use oid_to_hex_r() instead of memcpy()+oid_to_hex()
Message-ID: <xmqqzh7crf29.fsf@gitster.c.googlers.com>
URL: https://gitlist.dev/e/xmqqzh7crf29.fsf%40gitster.c.googlers.com
In-Reply-To: <632682d5-e343-c069-f4b4-0451072d54d2@web.de>

```
René Scharfe <l.s.r@web.de> writes:

> 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>
> ---

Thanks.

```
