<commit_before>package com.intellij.codeInsight.dataflow;

import java.util.HashSet;
import java.util.Set;

/**
 * @author: oleg
 */
public class SetUtil {
  private SetUtil() {
  }

  /**
   * Intersects two sets
   */
  public static <T> Set<T> intersect(final Set<T> set1, final Set<T> set2) {
    if (set1.equals(set2)){
      return set1;
    }
    final HashSet<T> result = new HashSet<T>();
    Set<T> minSet;
    Set<T> otherSet;
    if (set1.size() < set2.size()){
      minSet = set1;
      otherSet = set2;
    } else {
      minSet = set2;
      otherSet = set1;
    }
    for (T s : minSet) {
      if (otherSet.contains(s)){
        result.add(s);
      }
    }
    return result;
  }
}<commit_msg>npe fix<commit_after>package com.intellij.codeInsight.dataflow;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 * @author oleg
 */
public class SetUtil {
  private SetUtil() {
  }

  /**
   * Intersects two sets
   */
  @NotNull
  public static <T> Set<T> intersect(@Nullable Set<T> set1, @Nullable Set<T> set2) {
    if (set1 == null && set2 == null) {
      return Collections.emptySet();
    }
    if (set1 == null) {
      return set2;
    }
    if (set2 == null) {
      return set1;
    }
    if (set1.equals(set2)) {
      return set1;
    }
    Set<T> result = new HashSet<T>();
    Set<T> minSet;
    Set<T> otherSet;
    if (set1.size() < set2.size()) {
      minSet = set1;
      otherSet = set2;
    }
    else {
      minSet = set2;
      otherSet = set1;
    }
    for (T s : minSet) {
      if (otherSet.contains(s)) {
        result.add(s);
      }
    }
    return result;
  }
}
{'fraction_non_alphanumeric': 0.146242774566474, 'fraction_numerical': 0.016184971098265895, 'mean_word_length': 2.272211720226843, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, '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': '5832649', 'n_tokens_mistral': 648, 'n_tokens_neox': 638, 'n_words': 144}