@matheusbsbs / matheus-bagliano / commits / d070e3a31b
Fork 0

Name hash fixups: export (and rename) remove_hash_entry

This makes the name hash removal function (which really just sets the bit that disables lookups of it) available to external routines, and makes read_cache_unmerged() use it when it drops an unmerged entry from the index. It's renamed to remove_index_entry(), and we drop the (unused) 'istate' argument. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Linus Torvalds committed Feb 22, 2008 at 20:39 UTC d070e3a31bf94de1ef503b155a5e028545f7decc
3 files changed +17 -16
builtin-read-tree.c
+1
@@ -41,6 +41,7 @@ static int read_cache_unmerged(void)
41 for (i = 0; i < active_nr; i++) {
42 struct cache_entry *ce = active_cache[i];
43 if (ce_stage(ce)) {
44 + remove_index_entry(ce);
45 if (last && !strcmp(ce->name, last->name))
46 continue;
47 cache_tree_invalidate_path(active_cache_tree, ce->name);
cache.h
+14
@@ -137,6 +137,20 @@ struct cache_entry {
137 #define CE_HASHED (0x100000)
138 #define CE_UNHASHED (0x200000)
139
140 +/*
141 + * We don't actually *remove* it, we can just mark it invalid so that
142 + * we won't find it in lookups.
143 + *
144 + * Not only would we have to search the lists (simple enough), but
145 + * we'd also have to rehash other hash buckets in case this makes the
146 + * hash bucket empty (common). So it's much better to just mark
147 + * it.
148 + */
149 +static inline void remove_index_entry(struct cache_entry *ce)
150 +{
151 + ce->ce_flags |= CE_UNHASHED;
152 +}
153 +
154 static inline unsigned create_ce_flags(size_t len, unsigned stage)
155 {
156 if (len >= CE_NAMEMASK)
read-cache.c
+2 -16
@@ -70,25 +70,11 @@ static void set_index_entry(struct index_state *istate, int nr, struct cache_ent
70 hash_index_entry(istate, ce);
71 }
72
73 -/*
74 - * We don't actually *remove* it, we can just mark it invalid so that
75 - * we won't find it in lookups.
76 - *
77 - * Not only would we have to search the lists (simple enough), but
78 - * we'd also have to rehash other hash buckets in case this makes the
79 - * hash bucket empty (common). So it's much better to just mark
80 - * it.
81 - */
82 -static void remove_hash_entry(struct index_state *istate, struct cache_entry *ce)
83 -{
84 - ce->ce_flags |= CE_UNHASHED;
85 -}
86 -
73 static void replace_index_entry(struct index_state *istate, int nr, struct cache_entry *ce)
74 {
75 struct cache_entry *old = istate->cache[nr];
76
91 - remove_hash_entry(istate, old);
77 + remove_index_entry(old);
78 set_index_entry(istate, nr, ce);
79 istate->cache_changed = 1;
80 }
@@ -417,7 +403,7 @@ int remove_index_entry_at(struct index_state *istate, int pos)
403 {
404 struct cache_entry *ce = istate->cache[pos];
405
420 - remove_hash_entry(istate, ce);
406 + remove_index_entry(ce);
407 istate->cache_changed = 1;
408 istate->cache_nr--;
409 if (pos >= istate->cache_nr)