git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 14/20] sha1-array: convert internal storage for struct sha1_array to object_id

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 31, 2017, 15:42 UTC
Message-ID
<xmqqefxd1mhy.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170331014001.953484-15-sandals@crustytoothpaste.net>
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
>  	for (i = 0; i < array->nr; i++) {
> -		strbuf_addstr(&joined_hexs, sha1_to_hex(array->sha1[i]));
> +		strbuf_addstr(&joined_hexs, oid_to_hex(array->oid + i));

As I said in the previous round (in my comment on the one that corresponds to the next patch, which has been updated in this round), this converts E1[E2] to E1 + E2.

Show 6 quoted lines
> @@ -621,7 +621,7 @@ static void bisect_rev_setup(struct rev_info *revs, const char *prefix,
>  	argv_array_pushf(&rev_argv, bad_format, oid_to_hex(current_bad_oid));
>  	for (i = 0; i < good_revs.nr; i++)
>  		argv_array_pushf(&rev_argv, good_format,
> -				 sha1_to_hex(good_revs.sha1[i]));
> +				 oid_to_hex(good_revs.oid + i));
Likewise.
Show 10 quoted lines
> @@ -715,9 +715,9 @@ static struct commit **get_bad_and_good_commits(int *rev_nr)
>  	int i, n = 0;
>  
>  	ALLOC_ARRAY(rev, 1 + good_revs.nr);
> -	rev[n++] = get_commit_reference(current_bad_oid->hash);
> +	rev[n++] = get_commit_reference(current_bad_oid);
>  	for (i = 0; i < good_revs.nr; i++)
> -		rev[n++] = get_commit_reference(good_revs.sha1[i]);
> +		rev[n++] = get_commit_reference(good_revs.oid + i);
>  	*rev_nr = n;
Likewise.
Show 7 quoted lines
> @@ -53,9 +53,9 @@ int sha1_array_for_each_unique(struct sha1_array *array,
>  
>  	for (i = 0; i < array->nr; i++) {
>  		int ret;
> -		if (i > 0 && !hashcmp(array->sha1[i], array->sha1[i-1]))
> +		if (i > 0 && !oidcmp(array->oid + i, array->oid + i - 1))
>  			continue;
Likewise.
Show 13 quoted lines
> diff --git a/shallow.c b/shallow.c
> index 11f7dde9d9..dc7b67a294 100644
> --- a/shallow.c
> +++ b/shallow.c
> @@ -273,7 +273,7 @@ static int write_shallow_commits_1(struct strbuf *out, int use_pack_protocol,
>  	if (!extra)
>  		return data.count;
>  	for (i = 0; i < extra->nr; i++) {
> -		strbuf_addstr(out, sha1_to_hex(extra->sha1[i]));
> +		strbuf_addstr(out, oid_to_hex(extra->oid + i));
>  		strbuf_addch(out, '\n');
>  		data.count++;
>  	}
Likewise.
Show 16 quoted lines
> @@ -417,13 +417,13 @@ void clear_shallow_info(struct shallow_info *info)
>  
>  void remove_nonexistent_theirs_shallow(struct shallow_info *info)
>  {
> -	unsigned char (*sha1)[20] = info->shallow->sha1;
> +	struct object_id *oid = info->shallow->oid;
>  	int i, dst;
>  	trace_printf_key(&trace_shallow, "shallow: remove_nonexistent_theirs_shallow\n");
>  	for (i = dst = 0; i < info->nr_theirs; i++) {
>  		if (i != dst)
>  			info->theirs[dst] = info->theirs[i];
> -		if (has_sha1_file(sha1[info->theirs[i]]))
> +		if (has_object_file(oid + info->theirs[i]))
>  			dst++;
>  	}
>  	info->nr_theirs = dst;
Likewise.

It is so minor that there is no point rerolling the whole thing only for these, though.

Thanks.
Previous: brian m. carlsonNext: brian m. carlson
Message 11 of 24 in “object_id part 7”
  1. 00/20 object_id part 7brian m. carlson, Mar 31, 2017
  2. 04/20 builtin/diff: convert to struct object_idbrian m. carlson, Mar 31, 2017
  3. 09/20 test-sha1-array: convert most code to struct object_idbrian m. carlson, Mar 31, 2017
  4. 13/20 builtin/pull: convert to struct object_idbrian m. carlson, Mar 31, 2017
  5. 15/20 Make sha1_array_append take a struct object_id *brian m. carlson, Mar 31, 2017
  6. 12/20 submodule: convert check_for_new_submodule_commits to object_idbrian m. carlson, Mar 31, 2017
  7. 16/20 Convert remaining callers of sha1_array_lookup to object_idbrian m. carlson, Mar 31, 2017
  8. 19/20 Rename sha1_array to oid_arraybrian m. carlson, Mar 31, 2017
  9. 20/20 Documentation: update and rename api-sha1-array.txtbrian m. carlson, Mar 31, 2017
  10. 14/20 sha1-array: convert internal storage for struct sha1_array to object_idbrian m. carlson, Mar 31, 2017
  11. Junio C HamanoMar 31, 2017
  12. 18/20 Convert sha1_array_for_each_unique and for_each_abbrev to object_idbrian m. carlson, Mar 31, 2017
  13. 07/20 fsck: convert init_skiplist to struct object_idbrian m. carlson, Mar 31, 2017
  14. 17/20 Convert sha1_array_lookup to take struct object_idbrian m. carlson, Mar 31, 2017
  15. 11/20 sha1_name: convert disambiguate_hint_fn to take object_idbrian m. carlson, Mar 31, 2017
  16. 08/20 parse-options-cb: convert sha1_array_append caller to struct object_idbrian m. carlson, Mar 31, 2017
  17. 10/20 sha1_name: convert struct disambiguate_state to object_idbrian m. carlson, Mar 31, 2017
  18. 01/20 Define new hash-size constants for allocating memorybrian m. carlson, Mar 31, 2017
  19. 03/20 Convert GIT_SHA1_RAWSZ used for allocation to GIT_MAX_RAWSZbrian m. carlson, Mar 31, 2017
  20. 05/20 builtin/pull: convert portions to struct object_idbrian m. carlson, Mar 31, 2017
  21. 06/20 builtin/receive-pack: convert portions to struct object_idbrian m. carlson, Mar 31, 2017
  22. René ScharfeJul 15, 2017
  23. 02/20 Convert GIT_SHA1_HEXSZ used for allocation to GIT_MAX_HEXSZbrian m. carlson, Mar 31, 2017
  24. Junio C HamanoMar 31, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.