Skip to content

Commit 45a14f5

Browse files
rscharfegitster
authored andcommitted
Revert "name-rev: release unused name strings"
This reverts commit 2d53975. 3656f84 (name-rev: prefer shorter names over following merges, 2021-12-04) broke the assumption of 2d53975 (name-rev: release unused name strings, 2020-02-04) that a better name for a child is a better name for all of its ancestors as well, because it added a penalty for generation > 0. This leads to strings being free(3)'d that are still needed. 079f970 (name-rev: sort tip names before applying, 2020-02-05) already reduced the number of free(3) calls for the use case that motivated the original patch (name-rev --all in the Chromium repository) from ca. 44000 to 5, and 3656f84 eliminated even those few. So this revert won't affect name-rev's performance on that particular repo. Reported-by: Thomas Hurst <[email protected]> Helped-by: Elijah Newren <[email protected]> Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3656f84 commit 45a14f5

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

builtin/name-rev.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#define CUTOFF_DATE_SLOP 86400
1818

1919
struct rev_name {
20-
char *tip_name;
20+
const char *tip_name;
2121
timestamp_t taggerdate;
2222
int generation;
2323
int distance;
@@ -34,7 +34,7 @@ static struct commit_rev_name rev_names;
3434

3535
static int is_valid_rev_name(const struct rev_name *name)
3636
{
37-
return name && (name->generation || name->tip_name);
37+
return name && name->tip_name;
3838
}
3939

4040
static struct rev_name *get_commit_rev_name(const struct commit *commit)
@@ -96,20 +96,9 @@ static struct rev_name *create_or_update_name(struct commit *commit,
9696
{
9797
struct rev_name *name = commit_rev_name_at(&rev_names, commit);
9898

99-
if (is_valid_rev_name(name)) {
100-
if (!is_better_name(name, taggerdate, generation, distance, from_tag))
101-
return NULL;
102-
103-
/*
104-
* This string might still be shared with ancestors
105-
* (generation > 0). We can release it here regardless,
106-
* because the new name that has just won will be better
107-
* for them as well, so name_rev() will replace these
108-
* stale pointers when it processes the parents.
109-
*/
110-
if (!name->generation)
111-
free(name->tip_name);
112-
}
99+
if (is_valid_rev_name(name) &&
100+
!is_better_name(name, taggerdate, generation, distance, from_tag))
101+
return NULL;
113102

114103
name->taggerdate = taggerdate;
115104
name->generation = generation;

0 commit comments

Comments
 (0)