bool ts_subtree_eq()

in lib/src/subtree.c [560:589]


bool ts_subtree_eq(Subtree self, Subtree other) {
  if (self.data.is_inline || other.data.is_inline) {
    return memcmp(&self, &other, sizeof(SubtreeInlineData)) == 0;
  }

  if (self.ptr) {
    if (!other.ptr) return false;
  } else {
    return !other.ptr;
  }

  if (self.ptr->symbol != other.ptr->symbol) return false;
  if (self.ptr->visible != other.ptr->visible) return false;
  if (self.ptr->named != other.ptr->named) return false;
  if (self.ptr->padding.bytes != other.ptr->padding.bytes) return false;
  if (self.ptr->size.bytes != other.ptr->size.bytes) return false;
  if (self.ptr->symbol == ts_builtin_sym_error) return self.ptr->lookahead_char == other.ptr->lookahead_char;
  if (self.ptr->child_count != other.ptr->child_count) return false;
  if (self.ptr->child_count > 0) {
    if (self.ptr->visible_child_count != other.ptr->visible_child_count) return false;
    if (self.ptr->named_child_count != other.ptr->named_child_count) return false;

    for (uint32_t i = 0; i < self.ptr->child_count; i++) {
      if (!ts_subtree_eq(self.ptr->children[i], other.ptr->children[i])) {
        return false;
      }
    }
  }
  return true;
}