From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git Mailing List <git@vger.kernel.org>,
Matheus Tavares <matheus.bernardino@usp.br>
Subject: Re: [PATCH] bisect: use oid_to_hex_r() instead of memcpy()+oid_to_hex()
Date: Sun, 26 Jul 2020 19:02:14 +0000 [thread overview]
Message-ID: <20200726190214.GB6540@camp.crustytoothpaste.net> (raw)
In-Reply-To: <c2f9ec40-71f5-122c-add8-08d6a4bfa859@web.de>
[-- Attachment #1: Type: text/plain, Size: 1179 bytes --]
On 2020-07-26 at 17:41:12, René Scharfe wrote:
> 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.
>
> Signed-off-by: René Scharfe <l.s.r@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;
Yeah, this seems better in pretty much every way, and as a nice perk we
lose an explicit dependency on the_hash_algo.
--
brian m. carlson: Houston, Texas, US
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
prev parent reply other threads:[~2020-07-26 19:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-26 17:41 [PATCH] bisect: use oid_to_hex_r() instead of memcpy()+oid_to_hex() René Scharfe
2020-07-26 19:02 ` brian m. carlson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200726190214.GB6540@camp.crustytoothpaste.net \
--to=sandals@crustytoothpaste.net \
--cc=git@vger.kernel.org \
--cc=l.s.r@web.de \
--cc=matheus.bernardino@usp.br \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).