Re: [PATCH] type_from_string_gently: make sure length matches

2015-04-17 Thread Junio C Hamano
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

Re: [PATCH] type_from_string_gently: make sure length matches

2015-04-17 Thread Jeff King
On Fri, Apr 17, 2015 at 01:54:27PM -0700, Junio C Hamano wrote: > > Since the strings we are matching are literals, we could also record > > their sizes in the object_type_strings array and check the length first > > before even calling strncmp. I doubt this is a performance hot-spot, > > though.

Re: [PATCH] type_from_string_gently: make sure length matches

2015-04-17 Thread Junio C Hamano
Jeff King writes: > When commit fe8e3b7 refactored type_from_string to allow > input that was not NUL-terminated, it switched to using > strncmp instead of strcmp. But this means we check only the > first "len" bytes of the strings, and ignore any remaining > bytes in the object_type_string. We s

[PATCH] type_from_string_gently: make sure length matches

2015-04-17 Thread Jeff King
When commit fe8e3b7 refactored type_from_string to allow input that was not NUL-terminated, it switched to using strncmp instead of strcmp. But this means we check only the first "len" bytes of the strings, and ignore any remaining bytes in the object_type_string. We should make sure that it is als