Re: [PATCH] type_from_string_gently: make sure length matches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King <peff@xxxxxxxx> writes:

> 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 ;-)
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]