Strip namelen out of ce_flags into a ce_namelen field
Strip the name length from the ce_flags field and move it into its own ce_namelen field in struct cache_entry. This will both give us a tiny bit of a performance enhancement when working with long pathnames and is a refactoring for more readability of the code. It enhances readability, by making it more clear what is a flag, and where the length is stored and make it clear which functions use stages in comparisions and which only use the length. It also makes CE_NAMEMASK private, so that users don't mistakenly write the name length in the flags. Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
01388518c3
commit
b60e188c51
@ -73,7 +73,8 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,
|
||||
hashcpy(ce->sha1, sha1);
|
||||
memcpy(ce->name, base, baselen);
|
||||
memcpy(ce->name + baselen, pathname, len - baselen);
|
||||
ce->ce_flags = create_ce_flags(len, 0) | CE_UPDATE;
|
||||
ce->ce_flags = create_ce_flags(0) | CE_UPDATE;
|
||||
ce->ce_namelen = len;
|
||||
ce->ce_mode = create_ce_mode(mode);
|
||||
add_cache_entry(ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user