]> git.ipfire.org Git - thirdparty/git.git/blobdiff - bloom.c
commit-graph: pass a 'struct repository *' in more places
[thirdparty/git.git] / bloom.c
diff --git a/bloom.c b/bloom.c
index 6c7611847ad05cb95103177ca00e7824f42b63c1..cd9380ac623d4a01ec04ebd2110747e756c70df4 100644 (file)
--- a/bloom.c
+++ b/bloom.c
@@ -33,15 +33,16 @@ static int load_bloom_filter_from_graph(struct commit_graph *g,
                                        struct commit *c)
 {
        uint32_t lex_pos, start_index, end_index;
+       uint32_t graph_pos = commit_graph_position(c);
 
-       while (c->graph_pos < g->num_commits_in_base)
+       while (graph_pos < g->num_commits_in_base)
                g = g->base_graph;
 
-       /* The commit graph commit 'c' lives in doesn't carry bloom filters. */
+       /* The commit graph commit 'c' lives in doesn't carry Bloom filters. */
        if (!g->chunk_bloom_indexes)
                return 0;
 
-       lex_pos = c->graph_pos - g->num_commits_in_base;
+       lex_pos = graph_pos - g->num_commits_in_base;
 
        end_index = get_be32(g->chunk_bloom_indexes + 4 * lex_pos);
 
@@ -186,24 +187,22 @@ struct bloom_filter *get_bloom_filter(struct repository *r,
        struct diff_options diffopt;
        int max_changes = 512;
 
-       if (bloom_filters.slab_size == 0)
+       if (!bloom_filters.slab_size)
                return NULL;
 
        filter = bloom_filter_slab_at(&bloom_filters, c);
 
        if (!filter->data) {
                load_commit_graph_info(r, c);
-               if (c->graph_pos != COMMIT_NOT_FROM_GRAPH &&
-                       r->objects->commit_graph->chunk_bloom_indexes) {
-                       if (load_bloom_filter_from_graph(r->objects->commit_graph, filter, c))
+               if (commit_graph_position(c) != COMMIT_NOT_FROM_GRAPH &&
+                       load_bloom_filter_from_graph(r->objects->commit_graph, filter, c))
                                return filter;
-                       else
-                               return NULL;
-               }
        }
 
-       if (filter->data || !compute_if_not_present)
+       if (filter->data)
                return filter;
+       if (!compute_if_not_present)
+               return NULL;
 
        repo_diff_setup(r, &diffopt);
        diffopt.flags.recursive = 1;