diff options
author | Thomas Gummerer <t.gummerer@gmail.com> | 2012-07-11 11:22:37 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-07-11 09:42:45 -0700 |
commit | b60e188c51242b72061b5f2f0d4df80397f6125a (patch) | |
tree | a98bd286f05bca385fba527f3c7971a86cc78c14 /tree.c | |
parent | 01388518c30c20ccbbb9f99e00314ef291ecda37 (diff) | |
download | git-b60e188c51242b72061b5f2f0d4df80397f6125a.tar.gz git-b60e188c51242b72061b5f2f0d4df80397f6125a.tar.xz |
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>
Diffstat (limited to 'tree.c')
-rw-r--r-- | tree.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -22,7 +22,8 @@ static int read_one_entry_opt(const unsigned char *sha1, const char *base, int b ce = xcalloc(1, size); ce->ce_mode = create_ce_mode(mode); - ce->ce_flags = create_ce_flags(baselen + len, stage); + ce->ce_flags = create_ce_flags(stage); + ce->ce_namelen = baselen + len; memcpy(ce->name, base, baselen); memcpy(ce->name + baselen, pathname, len+1); hashcpy(ce->sha1, sha1); @@ -133,8 +134,8 @@ static int cmp_cache_name_compare(const void *a_, const void *b_) ce1 = *((const struct cache_entry **)a_); ce2 = *((const struct cache_entry **)b_); - return cache_name_compare(ce1->name, ce1->ce_flags, - ce2->name, ce2->ce_flags); + return cache_name_stage_compare(ce1->name, ce1->ce_namelen, ce_stage(ce1), + ce2->name, ce2->ce_namelen, ce_stage(ce2)); } int read_tree(struct tree *tree, int stage, struct pathspec *match) |