untested, exfiltrated from the old ipad I wrote it on via qr code after multiple sudden reboots
diff --git a/datagen/process2.cpp b/datagen/process2.cpp
index 1e59d6e..b8388ff 100644
--- a/datagen/process2.cpp
+++ b/datagen/process2.cpp
@@ -49,6 +49,20 @@ struct oid_pair_hash
}
};
+struct repo_commits
+{
+ ckkxlib2::repository repository;
+ std::vector<cxxlib2::oid> commits;
+ repo_commits(char const * path)
+ : repository(cxxlib2::repository::open(path))
+ {
+ repository.for_each_commit([](const cxxlib2::commit & c)
+ {
+ commits.push_back(c.id());
+ });
+ }
+};
+
int main(int argc, char **argv)
{
int max_diffs_per_commit = 1;
@@ -72,16 +86,19 @@ int main(int argc, char **argv)
srand(seed);
+ static thread_local unordered_map<string, repo_commits> repos;
+
for (unsigned int repo_cycle = 0; repo_cycle < cycles_over_repos; ++ repo_cycle)
{
for (char **pathptr = &argv[1]; pathptr != &argv[argc]; ++ pathptr)
{
- auto repository = repository::open(*pathptr);
- static thread_local vector<oid> commit_oids;
- repository.for_each_commit([](const commit & c)
- {
- commit_oids.push_back(c.id());
- });
+ if (!repos.count(*pathptr)) {
+ repos.emplace(*pathptr, *pathptr);
+ }
+ repo_commits & repo_entry = repos[*pathptr];
+ auto & repository = repo_entry.repository;
+ auto & commit_oids = repo_entry.commits;
+
random_shuffle(commit_oids.begin(), commit_oids.end());
int commits_output = 0;