Merge branch 'rs/commit-parsing-optim' into maint
The code that parses header fields in the commit object has been updated for (micro)performance and code hygiene. * rs/commit-parsing-optim: commit: don't check for space twice when looking for header commit: be more precise when searching for headersmaint
						commit
						d6bc22e64b
					
				
							
								
								
									
										22
									
								
								commit.c
								
								
								
								
							
							
						
						
									
										22
									
								
								commit.c
								
								
								
								
							|  | @ -1308,11 +1308,11 @@ void for_each_mergetag(each_mergetag_fn fn, struct commit *commit, void *data) | ||||||
|  |  | ||||||
| static inline int standard_header_field(const char *field, size_t len) | static inline int standard_header_field(const char *field, size_t len) | ||||||
| { | { | ||||||
| 	return ((len == 4 && !memcmp(field, "tree ", 5)) || | 	return ((len == 4 && !memcmp(field, "tree", 4)) || | ||||||
| 		(len == 6 && !memcmp(field, "parent ", 7)) || | 		(len == 6 && !memcmp(field, "parent", 6)) || | ||||||
| 		(len == 6 && !memcmp(field, "author ", 7)) || | 		(len == 6 && !memcmp(field, "author", 6)) || | ||||||
| 		(len == 9 && !memcmp(field, "committer ", 10)) || | 		(len == 9 && !memcmp(field, "committer", 9)) || | ||||||
| 		(len == 8 && !memcmp(field, "encoding ", 9))); | 		(len == 8 && !memcmp(field, "encoding", 8))); | ||||||
| } | } | ||||||
|  |  | ||||||
| static int excluded_header_field(const char *field, size_t len, const char **exclude) | static int excluded_header_field(const char *field, size_t len, const char **exclude) | ||||||
|  | @ -1322,8 +1322,7 @@ static int excluded_header_field(const char *field, size_t len, const char **exc | ||||||
|  |  | ||||||
| 	while (*exclude) { | 	while (*exclude) { | ||||||
| 		size_t xlen = strlen(*exclude); | 		size_t xlen = strlen(*exclude); | ||||||
| 		if (len == xlen && | 		if (len == xlen && !memcmp(field, *exclude, xlen)) | ||||||
| 		    !memcmp(field, *exclude, xlen) && field[xlen] == ' ') |  | ||||||
| 			return 1; | 			return 1; | ||||||
| 		exclude++; | 		exclude++; | ||||||
| 	} | 	} | ||||||
|  | @ -1354,12 +1353,11 @@ static struct commit_extra_header *read_commit_extra_header_lines( | ||||||
| 		strbuf_reset(&buf); | 		strbuf_reset(&buf); | ||||||
| 		it = NULL; | 		it = NULL; | ||||||
|  |  | ||||||
| 		eof = strchr(line, ' '); | 		eof = memchr(line, ' ', next - line); | ||||||
| 		if (next <= eof) | 		if (!eof) | ||||||
| 			eof = next; | 			eof = next; | ||||||
|  | 		else if (standard_header_field(line, eof - line) || | ||||||
| 		if (standard_header_field(line, eof - line) || | 			 excluded_header_field(line, eof - line, exclude)) | ||||||
| 		    excluded_header_field(line, eof - line, exclude)) |  | ||||||
| 			continue; | 			continue; | ||||||
|  |  | ||||||
| 		it = xcalloc(1, sizeof(*it)); | 		it = xcalloc(1, sizeof(*it)); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Junio C Hamano
						Junio C Hamano