<commit_before>#include "dependency_tree.hpp"

#include "osal.hpp"
#include "file_exist.hpp"
#include "resolver.hpp"
#include <algorithm>

Resolver *DependencyTree::addTarget(const std::string &fileName)
{
  auto &&res = tree.insert(std::make_pair(fileName, std::make_unique<Resolver>()));
  if (!res.second)
    throw std::runtime_error("Duplicated target: " + fileName);
  return res.first->second.get();
}

void DependencyTree::resolve()
{
  resolvedList.clear();
  for (auto &&target : tree)
    resolve(target.first);
}

// TODO run in parallel
void DependencyTree::resolve(const std::string &target)
{
  auto &&resolver = tree.find(target);
  if (resolver == std::end(tree))
  {
    resolvedList.insert(target);
    return;
  }
  time_t newestModificationTime = 0;
  for (auto &&dependency : resolver->second->dependencies)
  {<commit_msg>Fix multiple compilations for one file<commit_after>#include "dependency_tree.hpp"

#include "osal.hpp"
#include "file_exist.hpp"
#include "resolver.hpp"
#include <algorithm>

Resolver *DependencyTree::addTarget(const std::string &fileName)
{
  auto &&res = tree.insert(std::make_pair(fileName, std::make_unique<Resolver>()));
  if (!res.second)
    throw std::runtime_error("Duplicated target: " + fileName);
  return res.first->second.get();
}

void DependencyTree::resolve()
{
  resolvedList.clear();
  for (auto &&target : tree)
    resolve(target.first);
}

// TODO run in parallel
void DependencyTree::resolve(const std::string &target)
{
  if (resolvedList.find(target) != std::end(resolvedList))
    return;
  auto &&resolver = tree.find(target);
  if (resolver == std::end(tree))
  {
    resolvedList.insert(target);
    return;
  }
  time_t newestModificationTime = 0;
  for (auto &&dependency : resolver->second->dependencies)
  {
{'fraction_non_alphanumeric': 0.15565509518477044, 'fraction_numerical': 0.0011198208286674132, 'mean_word_length': 5.248251748251748, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7106886', 'n_tokens_mistral': 589, 'n_tokens_neox': 580, 'n_words': 123}