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

Re: [PATCH] type_from_string_gently: make sure length matches

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 17, 2015, 21:11 UTC
Message-ID
<xmqqzj66o3y2.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20150417210713.GA7403@peff.net>
Jeff King <peff@peff.net> writes:
Show 20 quoted lines
> I'd be surprised if it appreciably speeds things up, but I guess it is
> not too complicated to do.
>
>> +static struct {
>> +	const char *str;
>> +	int len;
>> +} object_type_name[] = {
>> +	{ NULL, 0 },      /* OBJ_NONE = 0 */
>> +	{ "commit", 6 },  /* OBJ_COMMIT = 1 */
>> +	{ "tree", 4 },	  /* OBJ_TREE = 2 */
>> +	{ "blob", 4 },    /* OBJ_BLOB = 3 */
>> +	{ "tag", 3 },     /* OBJ_TAG = 4 */
>>  };
>
> I had envisioned a macro like:
>
>   #define SIZED_STRING(x) { (x), (sizeof(x) - 1) }
>
> though perhaps that is overkill for such a short list (that we don't
> even expect to change).
Sounds good (either way ;-)
Previous: Jeff King
Message 4 of 4 in “type_from_string_gently: make sure length matches”
  1. type_from_string_gently: make sure length matchesJeff King, Apr 17, 2015
  2. Junio C HamanoApr 17, 2015
  3. Jeff KingApr 17, 2015
  4. Junio C HamanoApr 17, 2015

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.