bool SetU32::Block::includes()

in glean/rts/ownership/setu32.cpp [56:94]


bool SetU32::Block::includes(const SetU32::Block& other) const {
  if (hdr.id() != other.hdr.id()) {
    return false;
  }

  switch (hdr.type()) {
    case SetU32::Hdr::Sparse:
      return other.hdr.type() == SetU32::Hdr::Sparse
        && std::includes(
            sparse,
            sparse + hdr.sparseLen(),
            other.sparse,
            other.sparse + other.hdr.sparseLen());

    case SetU32::Hdr::Dense:
      switch (other.hdr.type()) {
        case SetU32::Hdr::Sparse: {
          const auto v = *dense;
          for (auto i = 0; i < other.hdr.sparseLen(); ++i) {
            if (!v.contains(other.sparse[i])) {
              return false;
            }
          }
          return true;
        }

        case SetU32::Hdr::Dense: {
          return dense->includes(*other.dense);
        }

        case SetU32::Hdr::Full:
          return false;
      }
      break;

    case SetU32::Hdr::Full:
      return true;
  }
}