struct strintmap idx_map;
struct strmap dir_rename_guess;
struct strmap *dir_rename_count;
- struct strset *relevant_source_dirs;
+ struct strintmap *relevant_source_dirs;
unsigned setup;
};
}
static void update_dir_rename_counts(struct dir_rename_info *info,
- struct strset *dirs_removed,
+ struct strintmap *dirs_removed,
const char *oldname,
const char *newname)
{
/* Get old_dir, skip if its directory isn't relevant. */
dirname_munge(old_dir);
if (info->relevant_source_dirs &&
- !strset_contains(info->relevant_source_dirs, old_dir))
+ !strintmap_contains(info->relevant_source_dirs, old_dir))
break;
/* Get new_dir */
}
}
- if (strset_contains(dirs_removed, old_dir))
+ if (strintmap_contains(dirs_removed, old_dir))
increment_count(info, old_dir, new_dir);
else
break;
}
static void initialize_dir_rename_info(struct dir_rename_info *info,
- struct strset *relevant_sources,
- struct strset *dirs_removed,
+ struct strintmap *relevant_sources,
+ struct strintmap *dirs_removed,
struct strmap *dir_rename_count)
{
struct hashmap_iter iter;
info->relevant_source_dirs = dirs_removed; /* might be NULL */
} else {
info->relevant_source_dirs = xmalloc(sizeof(struct strintmap));
- strset_init(info->relevant_source_dirs);
- strset_for_each_entry(relevant_sources, &iter, entry) {
+ strintmap_init(info->relevant_source_dirs, 0 /* unused */);
+ strintmap_for_each_entry(relevant_sources, &iter, entry) {
char *dirname = get_dirname(entry->key);
if (!dirs_removed ||
- strset_contains(dirs_removed, dirname))
- strset_add(info->relevant_source_dirs, dirname);
+ strintmap_contains(dirs_removed, dirname))
+ strintmap_set(info->relevant_source_dirs,
+ dirname, 0 /* value irrelevant */);
free(dirname);
}
}
}
static void cleanup_dir_rename_info(struct dir_rename_info *info,
- struct strset *dirs_removed,
+ struct strintmap *dirs_removed,
int keep_dir_rename_count)
{
struct hashmap_iter iter;
/* relevant_source_dirs */
if (info->relevant_source_dirs &&
info->relevant_source_dirs != dirs_removed) {
- strset_clear(info->relevant_source_dirs);
+ strintmap_clear(info->relevant_source_dirs);
FREE_AND_NULL(info->relevant_source_dirs);
}
const char *source_dir = entry->key;
struct strintmap *counts = entry->value;
- if (!strset_contains(dirs_removed, source_dir)) {
+ if (!strintmap_contains(dirs_removed, source_dir)) {
string_list_append(&to_remove, source_dir);
strintmap_clear(counts);
continue;
static int find_basename_matches(struct diff_options *options,
int minimum_score,
struct dir_rename_info *info,
- struct strset *relevant_sources,
- struct strset *dirs_removed)
+ struct strintmap *relevant_sources,
+ struct strintmap *dirs_removed)
{
/*
* When I checked in early 2020, over 76% of file renames in linux
/* Skip irrelevant sources */
if (relevant_sources &&
- !strset_contains(relevant_sources, filename))
+ !strintmap_contains(relevant_sources, filename))
continue;
/*
int minimum_score,
int copies,
struct dir_rename_info *info,
- struct strset *dirs_removed)
+ struct strintmap *dirs_removed)
{
int count = 0, i;
}
static void remove_unneeded_paths_from_src(int detecting_copies,
- struct strset *interesting)
+ struct strintmap *interesting)
{
int i, new_num_src;
continue;
/* If we don't care about the source path, skip it */
- if (interesting && !strset_contains(interesting, one->path))
+ if (interesting && !strintmap_contains(interesting, one->path))
continue;
if (new_num_src < i)
}
static void handle_early_known_dir_renames(struct dir_rename_info *info,
- struct strset *relevant_sources,
- struct strset *dirs_removed)
+ struct strintmap *relevant_sources,
+ struct strintmap *dirs_removed)
{
/*
* Not yet implemented; directory renames are determined via an
}
void diffcore_rename_extended(struct diff_options *options,
- struct strset *relevant_sources,
- struct strset *dirs_removed,
+ struct strintmap *relevant_sources,
+ struct strintmap *dirs_removed,
struct strmap *dir_rename_count)
{
int detect_rename = options->detect_rename;
/*
* dirs_removed: directories removed on a given side of history.
*/
- struct strset dirs_removed[3];
+ struct strintmap dirs_removed[3];
/*
* dir_rename_count: tracking where parts of a directory were renamed to
* If neither of those are true, we can skip rename detection for
* that path.
*/
- struct strset relevant_sources[3];
+ struct strintmap relevant_sources[3];
/*
* dir_rename_mask:
int i;
void (*strmap_func)(struct strmap *, int) =
reinitialize ? strmap_partial_clear : strmap_clear;
- void (*strset_func)(struct strset *) =
- reinitialize ? strset_partial_clear : strset_clear;
+ void (*strintmap_func)(struct strintmap *) =
+ reinitialize ? strintmap_partial_clear : strintmap_clear;
/*
* We marked opti->paths with strdup_strings = 0, so that we
/* Free memory used by various renames maps */
for (i = MERGE_SIDE1; i <= MERGE_SIDE2; ++i) {
- strset_func(&renames->dirs_removed[i]);
+ strintmap_func(&renames->dirs_removed[i]);
partial_clear_dir_rename_count(&renames->dir_rename_count[i]);
if (!reinitialize)
strmap_func(&renames->dir_renames[i], 0);
- strset_func(&renames->relevant_sources[i]);
+ strintmap_func(&renames->relevant_sources[i]);
}
if (!reinitialize) {
unsigned location_relevant = (dir_rename_mask == 0x07);
if (content_relevant || location_relevant)
- strset_add(&renames->relevant_sources[side], pathname);
+ strintmap_set(&renames->relevant_sources[side], pathname, 1);
}
one = alloc_filespec(pathname);
/* absent_mask = 0x07 - dirmask; sides = absent_mask/2 */
unsigned sides = (0x07 - dirmask)/2;
if (sides & 1)
- strset_add(&renames->dirs_removed[1], fullname);
+ strintmap_set(&renames->dirs_removed[1], fullname, 1);
if (sides & 2)
- strset_add(&renames->dirs_removed[2], fullname);
+ strintmap_set(&renames->dirs_removed[2], fullname, 1);
}
if (filemask == 0 || filemask == 7)
unsigned side_index)
{
return renames->pairs[side_index].nr > 0 &&
- !strset_empty(&renames->relevant_sources[side_index]);
+ !strintmap_empty(&renames->relevant_sources[side_index]);
}
static inline int possible_renames(struct rename_info *renames)
/* Initialization of various renames fields */
renames = &opt->priv->renames;
for (i = MERGE_SIDE1; i <= MERGE_SIDE2; i++) {
- strset_init_with_options(&renames->dirs_removed[i],
- NULL, 0);
+ strintmap_init_with_options(&renames->dirs_removed[i],
+ 0, NULL, 0);
strmap_init_with_options(&renames->dir_rename_count[i],
NULL, 1);
strmap_init_with_options(&renames->dir_renames[i],
NULL, 0);
- strset_init_with_options(&renames->relevant_sources[i],
- NULL, 0);
+ strintmap_init_with_options(&renames->relevant_sources[i],
+ 0, NULL, 0);
}
/*