From: Junio C Hamano Date: Fri, 17 Apr 2015 21:11:33 GMT Subject: Re: [PATCH] type_from_string_gently: make sure length matches Message-ID: In-Reply-To: <20150417210713.GA7403@peff.net> Jeff King 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 ;-)