<commit_before>var _ = require("lodash");

var getFlatDependencies = require("../modules/get-flat-dependencies");

module.exports = function settleExclusiveBundleModules(bundles) {
  var defaults = this.defaults;

  // Generate flat dependency arrays.
  _.each(bundles, function (bundle) {
    bundle.moduleHashes = getFlatDependencies(bundle.module);
  });

  // Remove explicit bundle modules and their dependencies from other bundles.
  _.each(bundles, function (bundleA) {
    _.each(bundles, function (bundleB) {
      if (bundleA !== bundleB && _.contains(bundleA.moduleHashes, bundleB.module.hash)) {
        bundleA.moduleHashes = _.difference(bundleA.moduleHashes, bundleB.moduleHashes);
      }
    });
  });

  // Create new bundles from the intersections of existing bundles.
  _.each(bundles, function (bundleA) {
    _.each(bundles, function (bundleB) {
      var intersection = _.intersection(bundleA.moduleHashes, bundleB.moduleHashes);
      if (intersection) {
        bundleA.moduleHashes = _.difference(bundleA.moduleHashes, intersection);
        bundleB.moduleHashes = _.difference(bundleB.moduleHashes, intersection);
        bundles.push({
          moduleHashes: intersection,
          dest: defaults.implicitBundleDest
        });
      }
    });
  });

  return bundles;
};<commit_msg>Only generate intersection bundles for bundles that are not equal.<commit_after>var _ = require("lodash");

var getFlatDependencies = require("../modules/get-flat-dependencies");

module.exports = function settleExclusiveBundleModules(bundles) {
  var defaults = this.defaults;

  // Generate flat dependency arrays.
  _.each(bundles, function (bundle) {
    bundle.moduleHashes = getFlatDependencies(bundle.module);
  });

  // Remove explicit bundle modules and their dependencies from other bundles.
  _.each(bundles, function (bundleA) {
    _.each(bundles, function (bundleB) {
      if (bundleA !== bundleB && _.contains(bundleA.moduleHashes, bundleB.module.hash)) {
        bundleA.moduleHashes = _.difference(bundleA.moduleHashes, bundleB.moduleHashes);
      }
    });
  });

  // Create new bundles from the intersections of existing bundles.
  _.each(bundles, function (bundleA) {
    _.each(bundles, function (bundleB) {
      var intersection;
      if (bundleA !== bundleB) {
        intersection = _.intersection(bundleA.moduleHashes, bundleB.moduleHashes);
        if (intersection) {
          bundleA.moduleHashes = _.difference(bundleA.moduleHashes, intersection);
          bundleB.moduleHashes = _.difference(bundleB.moduleHashes, intersection);
          bundles.push({
            moduleHashes: intersection,
            dest: defaults.implicitBundleDest
          });
        }
      }
    });
  });

  return bundles;
};
{'fraction_non_alphanumeric': 0.11566352429296592, 'fraction_numerical': 0.0, 'mean_word_length': 3.3517350157728707, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '661166', 'n_tokens_mistral': 792, 'n_tokens_neox': 760, 'n_words': 169}